Home > database >  How to query in elasticsearch?
How to query in elasticsearch?

Time:02-14

I am working on elastic search to fetch the record which contain string "bond"

{
  "query": {
    "match": {
      "name": "Bond"
    }
  }
}

but I am getting empty array as a output. Though multiple records are present containing string "bold" , but i am getting empty hits. (hits:[])

How to solve this issue?

I am using same query for another index and its working but for index named as "all_colleges", its not working. Its only returning the record when string is perfect match. i.e. "Bond" == "Bond"

CodePudding user response:

You can try with fuzziness:

{
  "query": {
    "match": {
      "name": {
         "query": "Bond",
         "fuzziness": "AUTO"
      }
    }
  }
}

CodePudding user response:

Actually there is many parameters you can add to get the results that you want in elastic search. Please check this link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html

You can try this one

{
    "query": {
        "match": {
            "name": {
                "query": "Bond",
                "fuzziness": "AUTO"
             }
         }
     }
}

`

  • Related