1

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?

3
  • Which version are you using, I have tested it in 2.4.4 and it worked fine. Commented Oct 12, 2017 at 6:00
  • I am using version 5.5.2. The phone field is number and all other fields are keywords. Does that have any impact? Commented Oct 12, 2017 at 13:09
  • I also noticed that this is working with text fields, but fails with keywords, long fields etc. Commented Oct 12, 2017 at 13:22

1 Answer 1

1

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!

Sign up to request clarification or add additional context in comments.

1 Comment

what do you mean when you say you change it from keyword fields to text? i heave the same issue :/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.