Good day! Installed elastikerc version 5.6 Morphological plugin https://github.com/imotov/elasticsearch-analysis-morphology I use the elasticsearch php library. Here is the code

$client = \Elasticsearch\ClientBuilder::create()->build(); $params = []; $params['index'] = ES_INDEX; //Удаляю индекс if($client->indices()->exists($params)){ $response = $client->indices()->delete($params); } //Создаю запись if(! $client->indices()->exists($params)){ $params = []; $params = [ 'index' => ES_INDEX, 'body' => [ 'settings' => [ 'analysis' => [ 'analyzer' => [ 'ru_analyzer' => [ 'type' => 'custom', 'tokenizer' => 'standard', 'filter' => ['lowercase', 'russian_morphology', 'english_morphology', 'snowball', 'ru_stemming'] ] ], 'filter' => [ 'ru_stemming' => [ 'type' => 'snowball', 'language' => 'Russian' ] ] ] ], 'mappings' => [ ES_INDEX => [ 'properties' => [ 'title' => [ 'type' => 'string', 'analyzer' => 'ru_analyzer', ] ] ] ] ] ]; $result = $client->indices()->create($params); } 

Next, I index the data

 $params = []; $params['index'] = ES_INDEX; $params['type'] = ES_TYPE; $params['id'] = 1; $params['body']['title'] = 'Тестовая метка; $params['body']['location'] = [ 'lat' => 50.1001, 'lon' => 25.1002 ]; $result = $client->index($params); 

The data is entered into elastic - if you search by ID - the record will return, but if you start searching by text:

 $params = []; $params['index'] = ES_INDEX; if ($client->indices()->exists($params)) { $params['type'] = ES_TYPE; $params['size'] = 10000; $params['body']['sort'] = ['_score' => 'desc']; $params['body']['query']['match']['title'] = 'тест'; $result = $client->search($params); } 

it finds nothing

Array ([took] => 0 [timed_out] => [_shards] => Array ([total] => 5 [successful] => 5 [skipped] => 0 [failed] => 0)

[hits] => Array ([total] => 0 [max_score] => [hits] => Array ()))

Please tell me what I'm doing wrong

    1 answer 1

    Try the query simple_query_string instead of match :

     $params = []; $params['index'] = ES_INDEX; if ($client->indices()->exists($params)) { $params['type'] = ES_TYPE; $params['size'] = 10000; $params['body']['sort'] = ['_score' => 'desc']; $params['body']['query']['simple_query_string'] = [ 'query' => 'тест', 'fields' => ['title'],//если не указать поле - будет поиск по всем ]; $result = $client->search($params); } 

    more information about this type of request can be found in the documentation https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-simple-query-string-query.html]