When I am creating an index in ElasticSearch and trying to use percolate, I had an error that field with percolate type is not exists in index. But when I'm watching in index, field exists.
I will show you mapping, how doc is looks like in index, error and query bellow.
Please help me! I really am trying everything I can find in the Google. Maybe someone knows what the problem.
Index Mapping:
'index' => 'stop-words',
'body' => [
'settings' => [
'number_of_shards' => 3,
'number_of_replicas' => 2,
'analysis' => [
'analyzer' => [
'simple_punctuation_analyzer' => [
'type' => 'custom',
'tokenizer' => 'simple_punctuation_tokenizer',
'char_filter' => ['html_strip'],
'filter' => ['lowercase']
]
],
'tokenizer' => [
'simple_punctuation_tokenizer' => [
'type' => 'char_group',
'tokenize_on_chars' => [
'whitespace',
',',
'.',
'\'',
'"',
':',
';',
'?',
'!'
]
]
]
]
],
'mappings' => [
'properties' => [
'id' => [
'type' => 'long'
],
'stop_word' => [
'type' => 'text',
'analyzer' => 'simple_punctuation_analyzer',
'fields' => [
'keyword' => [
'type' => 'keyword'
]
]
],
'stop_query' => [
'type' => 'percolator'
],
'status' => [
'type' => 'boolean'
],
]
]
]
];
Doc in index:
{
"_index": "stop-words",
"_type": "_doc",
"_id": "1",
"_score": 1.0,
"_source": {
"id": 1,
"stop_word": "asdasdasd",
"stop_query": {
"match_phrase": {
"stop_word": {
"query": "asdasdasd",
"analyzer": "simple_punctuation_analyzer"
}
}
}
}
},
Error:
Error: {"error":{"root_cause":
[{"type":"query_shard_exception",
"reason":"field [stop_query] does not exist",
"index_uuid":"I9ZjvdjCQuyHylKTDicRRg",
"index":"stop-words"}],
"type":"search_phase_execution_exception",
"reason":"all shards failed",
"phase":"query",
"grouped":true,
"failed_shards":[{"shard":0,"index":"stop-words",
"node":"PqSzl30DRnaNkFyp8RkOxg",
"reason":
{"type":"query_shard_exception",
"reason":"field [stop_query] does not exist",
"index_uuid":"I9ZjvdjCQuyHylKTDicRRg",
"index":"stop-words"}}]},"status":400}
My query:
'index' => StopWord::STOP_WORDS_ELASTICSEARCH_INDEX_NAME,
'_source' => ['id'],
'body' => [
'query' => [
'bool' => [
'filter' => [
['term' => ['status' => true]],
['percolate' => [
'field' => 'stop_query',
'documents' => $fields
]]
]
]
]
]