Highlight works incorrectly


(anhthu) #1

hi,

I'm now using ELS v.0.20.0. I have problem with highlighting.

My mapping:
curl -XPUT "http://:9200$ip/business?pretty=1" -d '
{
"mappings": {
"product": {
"properties": {
"productKey": {
"type": "long"
},
"denotation": {
"fields": {
"denotation": {
"type": "string",
"analyzer": "full_denotation"
},
"untouched" : {"type" : "string", "index" :
"not_analyzed"}
},
"type": "multi_field"
},
"alias": {
"properties" : {
"value" : {
"fields": {
"value": {
"type": "string",
"analyzer": "full_denotation"
},
"untouched" : {"type" : "string", "index" :
"not_analyzed"}
},
"type": "multi_field"
}
},
"type" : "nested"
}
}
}
},
"settings": {
"analysis": {
"filter": {
"denotation_snow": {
"type": "snowball",
"language": "German2"
}
},
"analyzer": {
"full_denotation": {
"filter": [
"standard",
"lowercase",
"icu_folding",
"denotation_snow"
],
"type": "custom",
"tokenizer": "standard"
}
}
}
}
}'


My data:
curl -XPUT 'http://$my_ip:9200/business/product/1' -d '{
"productKey":1,
"denotation":"Schienenpersonenfernverkehr (SPFV)",
"alias":[
{"value":"Kombiverkehr, Strasse-Schiene"},
{"value":"Kombiverkehr Strasse-Schiene, Containertransporte"},
{"value":"Kombiverkehr Strasse-Schiene, Betontransporte"},
{"value":"Kombiverkehr Strasse-Schiene,
Festbrennstofftransporte"}]
}'


My query:
{
"query": {
"bool": {
"should": [
{
"query_string": {
"query": "strass schien",
"fields": [
"denotation"
],
"use_dis_max": true,
"default_operator": "and",
"allow_leading_wildcard": true
}
},
{
"nested": {
"query": {
"query_string": {
"query": "strass schien",
"fields": [
"alias.value"
],
"use_dis_max": true,
"default_operator": "and",
"allow_leading_wildcard": true
}
},
"path": "alias"
}
}
],
"minimum_number_should_match": 1
}
},
"highlight": {
"require_field_match": true,
"fields": {
"denotation": {}
}
}
}

Although all operators are AND, the highlight seems to be incorrect:
Here is search result:
{

took: 2
timed_out: false
_shards: {
    total: 5
    successful: 5
    failed: 0
}
hits: {
    total: 1
    max_score: 0.57735026
    hits: [
        {
            _index: business
            _type: product
            _id: 1
            _score: 0.57735026
            _source: {
                productKey: 1
                denotation: Schienenpersonenfernverkehr (SPFV)
                alias: [
                    {
                        value: Kombiverkehr, Strasse-Schiene
                    }
                    {
                        value: Kombiverkehr Strasse-Schiene,

Containertransporte
}
{
value: Kombiverkehr Strasse-Schiene,
Betontransporte
}
{
value: Kombiverkehr Strasse-Schiene,
Festbrennstofftransporte
}
]
}
highlight: {
denotation: [
Schienenpersonenfernverkehr (SPFV)
]
}
}
]
}
}
I wonder why the denotation ""Schienenpersonenfernverkehr" is
highlighted when it just matched with 1 token (schien). If i
separate my query into 2 queries, one for nested object only and one
for query on denotation, both work fine.

The result I expected is:
{
took: 2
timed_out: false
_shards: {
total: 5
successful: 5
failed: 0
}
hits: {
total: 1
max_score: 0.57735026
hits: [
{
_index: business
_type: product
_id: 1
_score: 0.57735026
_source: {
productKey: 1
denotation: Schienenpersonenfernverkehr (SPFV)
alias: [
{
value: Kombiverkehr, Strasse-Schiene
}
{
value: Kombiverkehr Strasse-Schiene,
Containertransporte
}
{
value: Kombiverkehr Strasse-Schiene,
Betontransporte
}
{
value: Kombiverkehr Strasse-Schiene,
Festbrennstofftransporte
}
]
}
}
]
}
}

If anyone could help me on this, it's really appriciated, thanks so
much.

anhthu


(anhthu) #2

hi,

is there any help?

On Mar 20, 6:23 pm, Anh Thu dinhvuanh...@gmail.com wrote:

hi,

I'm now using ELS v.0.20.0. I have problem with highlighting.

My mapping:
curl -XPUT "http://:9200$ip/business?pretty=1" -d '
{
"mappings": {
"product": {
"properties": {
"productKey": {
"type": "long"
},
"denotation": {
"fields": {
"denotation": {
"type": "string",
"analyzer": "full_denotation"
},
"untouched" : {"type" : "string", "index" :
"not_analyzed"}
},
"type": "multi_field"
},
"alias": {
"properties" : {
"value" : {
"fields": {
"value": {
"type": "string",
"analyzer": "full_denotation"
},
"untouched" : {"type" : "string", "index" :
"not_analyzed"}
},
"type": "multi_field"
}
},
"type" : "nested"
}
}
}},

"settings": {
"analysis": {
"filter": {
"denotation_snow": {
"type": "snowball",
"language": "German2"
}
},
"analyzer": {
"full_denotation": {
"filter": [
"standard",
"lowercase",
"icu_folding",
"denotation_snow"
],
"type": "custom",
"tokenizer": "standard"
}
}
}
}

}'


My data:
curl -XPUT 'http://$my_ip:9200/business/product/1' -d '{
"productKey":1,
"denotation":"Schienenpersonenfernverkehr (SPFV)",
"alias":[
{"value":"Kombiverkehr, Strasse-Schiene"},
{"value":"Kombiverkehr Strasse-Schiene, Containertransporte"},
{"value":"Kombiverkehr Strasse-Schiene, Betontransporte"},
{"value":"Kombiverkehr Strasse-Schiene,
Festbrennstofftransporte"}]

}'


My query:
{
"query": {
"bool": {
"should": [
{
"query_string": {
"query": "strass schien",
"fields": [
"denotation"
],
"use_dis_max": true,
"default_operator": "and",
"allow_leading_wildcard": true
}
},
{
"nested": {
"query": {
"query_string": {
"query": "strass schien",
"fields": [
"alias.value"
],
"use_dis_max": true,
"default_operator": "and",
"allow_leading_wildcard": true
}
},
"path": "alias"
}
}
],
"minimum_number_should_match": 1
}
},
"highlight": {
"require_field_match": true,
"fields": {
"denotation": {}
}
}}


Although all operators are AND, the highlight seems to be incorrect:
Here is search result:
{

took: 2
timed_out: false
_shards: {
    total: 5
    successful: 5
    failed: 0
}
hits: {
    total: 1
    max_score: 0.57735026
    hits: [
        {
            _index: business
            _type: product
            _id: 1
            _score: 0.57735026
            _source: {
                productKey: 1
                denotation: Schienenpersonenfernverkehr (SPFV)
                alias: [
                    {
                        value: Kombiverkehr, Strasse-Schiene
                    }
                    {
                        value: Kombiverkehr Strasse-Schiene,

Containertransporte
}
{
value: Kombiverkehr Strasse-Schiene,
Betontransporte
}
{
value: Kombiverkehr Strasse-Schiene,
Festbrennstofftransporte
}
]
}
highlight: {
denotation: [
Schienenpersonenfernverkehr (SPFV)
]
}
}
]
}}

I wonder why the denotation ""Schienenpersonenfernverkehr" is
highlighted when it just matched with 1 token (schien). If i
separate my query into 2 queries, one for nested object only and one
for query on denotation, both work fine.

The result I expected is:
{
took: 2
timed_out: false
_shards: {
total: 5
successful: 5
failed: 0
}
hits: {
total: 1
max_score: 0.57735026
hits: [
{
_index: business
_type: product
_id: 1
_score: 0.57735026
_source: {
productKey: 1
denotation: Schienenpersonenfernverkehr (SPFV)
alias: [
{
value: Kombiverkehr, Strasse-Schiene
}
{
value: Kombiverkehr Strasse-Schiene,
Containertransporte
}
{
value: Kombiverkehr Strasse-Schiene,
Betontransporte
}
{
value: Kombiverkehr Strasse-Schiene,
Festbrennstofftransporte
}
]
}
}
]
}

}

If anyone could help me on this, it's really appriciated, thanks so
much.

anhthu


(system) #3