1
votes

I am running the below search query on my index

{
  "_source": "false", 
  "query": {
    "bool": {
      "must": [
        {
          "multi_match": {
            "fields": ["email","name", "company",  "phone"],
            "query": "tes",
            "type" : "phrase_prefix"
          }
        }
      ]
    }
  },
  "highlight": {
    "fields": {"name": {}, "company" : {}, "email" : {}, "phone" : {}}
  }
}

I have some sample data with the field values

name: test paddy
name : test user
name : test logger
name : test

When I run the above query, I do not get any results, but when I change it to "query": "test", I start seeing 1 result "test". I was expecting to see in both cases all the above names that i have. Am I missing something here?

UPDATE I also noticed that this is working with text fields, but fails with keywords, long fields etc Also, when I tried

{ "query": {
    "prefix" : { "phone" : 99 }
  }
}

with number fields and keyword fields its working.

So is it like multi_match and prefix don't work well with keyword and number fields?

1
Which version are you using, I have tested it in 2.4.4 and it worked fine. - sunkuet02
I am using version 5.5.2. The phone field is number and all other fields are keywords. Does that have any impact? - Paddy Mahadeva
I also noticed that this is working with text fields, but fails with keywords, long fields etc. - Paddy Mahadeva

1 Answers

1
votes

The issue was that I was running this on keyword fields. I changed it to text and worked like a beauty. Should have read the documentation more clearly!