Unexpected match_phrase_prefix query result

Any explanation why match_phrase_prefix search for "good m" failes while "good mo" search is successfull?
The doc in my index is:
{
"_index": "search_ltv_2017-04-02t08:40:01.000z",
"_type": "eng",
"_id": "uri:prg:pass-program-57464243~uri:scd:TV04:pass-program-57464243:05042017060000_eng",
"_source": {
"startTime": 1491372000000,
"duration": 3600000,
"endTime": 1491375600000,
"channelId": "TV04",
"title": "Good morning"
}

The document is returned by:
{
"query":
{ "bool":
{ "should":
[ { "match_phrase_prefix": { "title": "Good mo" } }]
}
}
}
But is not returned by:
{
"query":
{ "bool":
{ "should":
[ { "match_phrase_prefix": { "title": "Good m" } }]
}
}
}

Result is:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": [],
}
}

BTW, same works fine for other documents such as "Good evening" which is returned by "good e" match_phrase_prefix query. What can explain the failure for this specific document?

Can you provide the full mapping? I'm not able to reproduce your issue. I'm using ES 5.3.

PUT myprefix

POST myprefix/results
{
  "message" : "Good morning"
}

GET myprefix/results/_search
{
"query": 
{ "bool": 
{ "should": 
[ { "match_phrase_prefix": { "message": "Good mo" } }] 
} 
}
}

GET myprefix/results/_search
{ 
"query": 
{ "bool": 
{ "should": 
[ { "match_phrase_prefix": { "message": "Good m" } }] 
} 
} 
}

Both GET queries return the same results

{
  "took": 34,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 0.51623213,
    "hits": [
      {
        "_index": "myprefix",
        "_type": "results",
        "_id": "AVs65H7hIX8nR50qxS08",
        "_score": 0.51623213,
        "_source": {
          "message": "Good morning"
        }
      }
    ]
  }
}

I’m using 2.4.4, my mapping is:

{
    "settings":{
        "index":{
            "analysis":{
                "analyzer":{
                    "analyzer_keyword":{
                        "tokenizer":"keyword",
                        "filter":"lowercase"
                    }
                }
            }
         }
    },
    "mappings": {
        "_default_": {
            "properties": {
                "assetId": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "region": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "availability": {
                    "type": "nested",
                    "properties": {
                        "catalogId": {
                            "type": "string",
                            "index": "not_analyzed"
                        }
                    }
                },
                "contentId": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "startTime": {
                    "type": "date",
                    "index": "not_analyzed"
                },
                "title": {
                    "type": "string",
                    "copy_to": "title_and_cast",
                    "fields": {
                        "raw": {
                            "type": "string",
                            "index": "not_analyzed"
                        }
                    }
                },
                "actors": {
                    "type": "string",
                    "copy_to": "title_and_cast"
                },
                "directors": {
                    "type": "string",
                    "copy_to": "title_and_cast"
                },
                "title_and_cast": {
                    "type": "string",
                    "analyzer":"analyzer_keyword"
                }
            }
        }
    }
}

Do you have another version of ES you can try this on? I still can't reproduce your problem . I'm using ES 5.X and 2.3.

The search for 'good m' will expand to the first 50 (by default) 'm' words alphabetically found in the index - even if they have nothing to do with 'good' eg mad, made, map, mat etc That finds nothing.

Your search for 'good mo' might expand to something like moon, moose, morning and therefore match.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.