Hello,
I have incorrect highlight when I use span_or query in span_near query. For example:
My index settings:
curl -XPUT 'http://localhost:9200/highlighting/' -d '{
"settings": {
"analysis": {
"filter": {
"unique_filter": {
"type": "unique",
"only_on_same_position": true
}
},
"analyzer": {
"my_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [ "unique_filter" ]
}
}
}
},
"mappings": {
"highlight": {
"properties": {
"Text": {
"type": "string",
"analyzer": "my_analyzer"
},
"Id": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}'
Data:
curl -XPUT 'http://localhost:9200/highlighting/highlight/1' -d '{
"Id":1,
"Text":"Obama States President"
}'
I try to highlight by query:
curl -XPOST 'http://localhost:9200/highlighting/highlight/_search?pretty' -d '{
"query":{
"ids":{
"type":"highlight",
"values":["1"]
}
},
"highlight":{
"fields":{
"Text":{
"number_of_fragments":0,
"highlight_query":{
"span_near":{
"clauses":[
{
"span_term":{
"Text":"President"
}
},
{
"span_or":{
"clauses":[
{
"span_near":{
"clauses":[
{
"span_term":{
"Text":"United"
}
},
{
"span_term":{
"Text":"States"
}
}
],
"slop":0,
"in_order":true
}
},
{
"span_term":{
"Text":"Obama"
}
}
]
}
}
],
"slop":5,
"in_order":false
}
}
}
}
}
}'
I get the result:
"<em>Obama</em> <em>States</em> <em>President</em>"
It is not true. 'States'should not be highlighted.
If I run the equivalent query:
curl -XPOST 'http://localhost:9200/highlighting/highlight/_search?pretty' -d '{
"_source":false,
"query" : {
"ids" : {
"type" : "highlight",
"values" : ["1"]
}
},
"highlight" : {
"fields" : {
"Text" : {
"number_of_fragments" : 0,
"highlight_query":{
"simple_query_string":{
"query": "President NEAR/5 (\"United States\" | Obama)",
"fields": ["Text"],
"default_operator": "and"
}
}
}
}
}
}'
I get the correct result:
"<em>Obama</em> States <em>President</em>"
There is problem in ES1.7.1-5.0.0-alpha2. I can not use a simple_query_string for my tasks. Can anybody help me?
Many thanks,
Alexander