elasticsearch - Does analyzer prevent fields from highlighting? -


could me little problem regarding language-specific analyzers , highliting in elasticsearch?

i need search documents query string , highlight matched strings. here mapping:

{     "usr": {         "properties": {             "text0": {                 "type": "string",                 "analyzer": "english"             },             "text1": {                 "type": "string"             }         }     } } 

note, "text0" field "english" analyzer set, , "text1" field used standard analyzer default.

in index there 1 document now:

hits": [{     "_index": "tt",     "_type": "usr",     "_id": "auxvipav84ayqmzv-3ll",     "_score": 1,     "_source": {         "text0": "highlighted. need highlighted.",         "text1": "highlighted. need highlighted."     } }] 

consider following query:

{     "query": {         "query_string" : {             "query" : "highlighted"         }     },     "highlight" : {         "fields" : {             "*" : {}         }     } } 

i've expected each field in document highlighted, highlighting appeared in "text1" field (where no analyzer set):

"hits": [{     "_type": "usr",      "_source": {         "text0": "highlighted. need highlighted.",          "text1": "highlighted. need highlighted."     },      "_score": 0.19178301,      "_index": "tt",      "highlight": {         "text1": [             "<em>highlighted</em>. need <em>highlighted</em>."         ]     },      "_id": "auxvipav84ayqmzv-3ll" }] 

let's consider following query(i expected "highlighted" matches "highlight" because of analyzer):

{     "query": {         "query_string" : {                 "query" : "highlight"             }         },     "highlight" : {              "fields" : {                  "*" : {}              }         } } 

but there no hist in response @ all: (did english analyzer work here?)

"hits": {     "hits": [],      "total": 0,      "max_score": null } 

at last, consider curl commands (requests , 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, passing text through english , standard analyzers, result different. finally, question: analyzer prevent fields highlighting? how can fields highlighted while full-text search?

p.s. use elasticsearch v1.4.4 on local machine windows 8.1.

it has query. using query_string query , not specifying field searching on _all field default. why you're seeing strange results. change query multi_match query searches on both fields:

{     "query": {         "multi_match": {             "fields": [                 "text1",                 "text0"             ],             "query": "highlighted"         }     },     "highlight": {         "fields": {             "*": {}         }     } }  

now highlight results both fields returned in response.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -