0

I have a document in elasticsearch

  {"uuid":"eaa91372-d541-4b24-bdf4-3cb4902d2da1","artistName":"Amadeo Modigliani","Review":"abc","Origin":"pak","isNew":"false"}

I am using match query in my code to get the document it's returning the correct results on giving needed search values eg: "Amadeo Modigliani", or "Amadeo" or "Modigliani" but when I pass "Amad" only ES did not find the document ,Please suggest if there is any other query which will perform the search using this scanerio or is there any other way to perform this task ,Thanks

swaheed
  • 3,671
  • 10
  • 42
  • 103

1 Answers1

0

You are actually describing the partial matching feature of Elastic Search. Partial matching allows to specify a part of a word the user is looking for. It finds any words that contain this portion.

In your case, the Minimum Should Match could be solve your problem. It is a parameter that comes with match query feature (the minimum_should_match parameter ) and can be configured with values depending on how you want this feature to work.

Below is an example of using this parameter:

QueryBuilder qb = QueryBuilders
    .boolQuery()
    .must(termQuery("component", currentComponent))
    .should(termQuery("userId", currentUserId))
    .should(termQuery("customerId", currentCustomerId))
    .should(termQuery("currentRole", ADMIN))
    .minimumShouldMatch("2"); // or .minimumNumberShouldMatch(1)

You can find below the appropriate information about this concepts.

Match Query
Minimum Should Match