Hi all, could you help me with little problem regarding language-specific analyzers and highliting in elasticsearch?
I need search documents by a query string and highlight matched strings. Here is my mapping: { "usr": { "properties": { "text0": { "type": "string", "analyzer": "english" }, "text1": { "type": "string" } } } } Note, that for "text0" field "english" analyzer is set, and for "text1" field is used standard analyzer by default. In my index there is one document for now: hits": [{ "_index": "tt", "_type": "usr", "_id": "AUxvIPAv84ayQMZV-3Ll", "_score": 1, "_source": { "text0": "highlighted. need to be highlighted.", "text1": "highlighted. need to be highlighted." } }] Consider following query: { "query": { "query_string" : { "query" : "*highlighted*" } }, "highlight" : { "fields" : { "*" : {} } } } I've expected each field in the document to be highlighted, but highlighting appeared only in "text1" field (where is no analyzer set): "hits": [{ "_type": "usr", "_source": { "text0": "highlighted. need to be highlighted.", "text1": "highlighted. need to be highlighted." }, "_score": 0.19178301, "_index": "tt", "highlight": { "text1": [ "<em>highlighted</em>. need to be <em>highlighted</em>." ] }, "_id": "AUxvIPAv84ayQMZV-3Ll" }] Let's consider the following query(I expected "highlighted" matches "highlight" because of analyzer): { "query": { "query_string" : { "query" : "*highlight*" } }, "highlight" : { "fields" : { "*" : {} } } } But there was no hist in response at all: (Did the english analyzer even work here?) "hits": { "hits": [], "total": 0, "max_score": null } At last, consider some curl commands (requests and responses): curl "http://localhost:9200/tt/_analyze?field=text0" -d "highlighted" {"tokens":[{ "token":"*highlight*", "start_offset":0, "end_offset":11, "type":"<ALPHANUM>", "position":1 }]} curl "http://localhost:9200/tt/_analyze?field=text1" -d "highlighted" {"tokens":[{ "token":"*highlighted*", "start_offset":0, "end_offset":11, "type":"<ALPHANUM>", "position":1 }]} We see, by passing text through the english and standard analyzers, the result is different. Finally, the question: *does english analyzer prevent fields from highlighting? How can I get my fields highlighted while full-text search?* P.S. I use elasticsearch v1.4.4 on my local machine with windows 8.1. -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/59cea72f-08e3-42b2-ad0e-e5d5ba7762a8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.