Not able to make a search query match_all after I cahnged my field mapping


(Chitresh Jain) #1

Hello,

I have a field named "candidate_name". Initially, I had a mapping for this field like this -

"candidate_name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}

Now, I changed its mapping because I wanted to use completion Suggestor for this field -

This is how I defined it -
{
"mappings": {
"doc": {
"properties": {
"candidate_name": {
"type": "completion",
"analyzer": "simple",
"search_analyzer": "simple"
}
}
}
}
}

After applying this mapping to this field, I am not able to make a search query like this -

client.search(
{
index : "candidates",
body: {
query: {
multi_match: {
query: "chitresh"
}
}
}
)
I was able to make this query before ad get the result.

So, how to define its mapping, so that I can use completion suggestor for this field as well as I can make a search query for this field.

I have already gone through ES docs. Couldn't get the solution there.


(James Addison) #2

Use subfields. You were previously using them in your original example, you just need to add the completion subfield, I think?

{
  "candidate_name" : {
    "type" : "text",
    "fields" : {
      "keyword" : {
        "type" : "keyword",
        "ignore_above" : 256
      },
      "completion": {
        "type": "completion",
        "analyzer": "simple",
        "search_analyzer": "simple"
      }
    }
  }
}

Side note: it's always easier to get help if you've properly formatting your code/question.


(system) #3

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