PHP Unable to add docs to crafted mapping

Hi,

I am new the Elastisearch and finding it remarkably difficult to do simple tasks - e.g. create an index and add some data. I am really thinking I'll just dump it and look elsewhere unless I can get somewhere with this quickly.

I am using PHP 5.2.

I can add documents to an index where the mapping has been created "on the fly" by elasticsearch - both singly and in bulk. When I then create an index mapping that varies from the created mapping only slightly the adding of docments fail horribly. The exception is:
Elasticsearch\Common\Exceptions\ServerErrorResponseException which seems to be undocumented and the log reads:
nested: UnavailableShardsException[[appeals][4] Not enough active copies to meet write consistency of [QUORUM] (have 1, needed 2). Timeout: [1m]
According to HQ there are two copies so this makes no sense.

My code mapping is:
$params = array(
'index' => 'mytest',
'body' => array(
'settings' => array(
'number_of_shards' => 5,
'number_of_replicas' => 2,
'analysis' => array(
'analyzer' => array(
'bespoke' => array(
'type' => 'custom',
'tokenizer' => 'standard',
'filter' => array('lowercase', 'stop', 'kstem')
)
)
)
),
'mappings' => array(
"passed" => array(
"properties" => array(
"casetype_id" => array(
"type" => "long",
'index' => 'not_analyzed'
),
"decision_date" => array(
"format" => "strict_date_optional_time||epoch_millis",
"type" => "date"
),
"reference" => array(
"type" => "string",
'index' => 'not_analyzed'
),
"outcome_id" => array(
"type" => "long",
'index' => 'not_analyzed'
),
"case_id_id" => array(
"type" => "long",
'index' => 'not_analyzed'
),
"procedure_id" => array(
"type" => "long",
'index' => 'not_analyzed'
),
"case_summary" => array(
"type" => "string",
"analyzer" => "snowball"
),
"document_id" => array(
"type" => "long",
'index' => 'not_analyzed'
),
"authority_id" => array(
"type" => "long",
'index' => 'not_analyzed'
),
"r_id" => array(
"type" => "long",
'index' => 'not_analyzed'
),
"document_content" => array(
"type" => "string",
"analyzer" => "snowball"
)
)
)
)
)
);

which seems to create the index without a hitch. The only addition as far as I can see from the ES created index is the snowball analyzer.

Can anyone help?

Steve

I'd try to start with simple things and don't try to play with settings at the beginning.

Here, you changed the default value for the number of replicas.
It has an effect. It means that you need to have at least 2 nodes running in order to have a quorum.

I'd for now either set the number of replicas to 0 or to 1 (default).

Thanks! I was getting close to aiming at the window and practising for the PC lobbing championships.

No doubt I'll be back. :slightly_smiling:

Steve