php - How can I search with Unicode characters in elasticsearch? -
i have indexed mysql column elasticsearch , column have ar/en/ro languages values. how can search within these indexes unicode string ?
$hosts = ['localhost:9200']; $client = \elasticsearch\clientbuilder::create()->sethosts($hosts)->build(); $body = '{ "query": { "filtered": { "query": { "match_all": {} }, "filter": { "bool": { "must": [ {"query": {"wildcard": {"text": {"value": "*'.$term.'*"}}}}, {"query": {"wildcard": {"group": {"value": "hotels_cities"}}}} ] } } } }}'; $params['index'] = 'my_custom_index_name'; $params['type'] = 'translator_translations'; $params['body'] = $body; $results = $client->search($params);
the out put hits zero.
-there called analyzer there no information how use in php.
i think found answer of how index unicode languages characters in elasticsearch, hope useful one.
first have set index name
second set new language settings filter , language analyzer, this:
$client = clientbuilder::create() // instantiate new clientbuilder ->sethosts(['localhost:9200']) // set hosts ->build(); $lang = 'el'; // greek in case $param['index'] = 'test_' . $lang; // index name // uncomment line if want delete existing index // $response = $client->indices()->delete($param); $body = '{ "settings": { "analysis": { "filter": { "greek_stop": { "type": "stop", "stopwords": "_greek_" }, "greek_lowercase": { "type": "lowercase", "language": "greek" }, "greek_keywords": { "type": "keyword_marker", "keywords": ["παράδειγμα"] }, "greek_stemmer": { "type": "stemmer", "language": "greek" } }, "analyzer": { "greek": { "tokenizer": "standard", "filter": [ "greek_lowercase", "greek_stop", "greek_keywords", "greek_stemmer" ] } } } } }'; $param['body'] = $body; // store json body parameter in main array $response = $client->indices()->create($param);
then start indexing values greek characters
Comments
Post a Comment