hackerl33t
hackerl33t

Reputation: 2363

OrchardCore match_phrase doesn't return result

I have the following query

{
  "from": 0, "size": 10000,
  "query": { "match_phrase": {"Practitioner.DoctorList": "peter goh"} },
}

it doesn't return any result.

But the following:

{
  "from": 0, "size": 10000,
  "query": { "match": {"Practitioner.DoctorList": "peter goh"} },
}

returns content that has "peter goh", "peter", and "goh".

Why doesn't match_phrase return anything? As I only want the results to have matches with "peter goh".

Upvotes: 0

Views: 71

Answers (1)

Bhavya
Bhavya

Reputation: 16182

Since you have not added any sample data and index mapping, (considering Practitioner to be of nested type)

Refer match_phrase query, to get detailed information

Adding a working example with index data, mapping and search query.

Index Mapping:

{
  "mappings": {
    "properties": {
      "Practitioner": {
        "type": "nested" 
      }
    }
  }
}

Index Data:

{
    "Practitioner": [
        {
            "DoctorList": "goh"
        },
        {
            "DoctorList": "peter goh"
        },
        {
            "DoctorList": "peter"
        }
    ]
}

Search Query:

    {
  "query": {
    "nested": {
      "path": "Practitioner",
      "query": {
        "match_phrase": {
          "Practitioner.DoctorList": "peter goh"
        }
      },
      "inner_hits":{}
    }
  }
}

Search Result:

"hits": [
                {
                  "_index": "fd_cb3",
                  "_type": "_doc",
                  "_id": "1",
                  "_nested": {
                    "field": "Practitioner",
                    "offset": 1
                  },
                  "_score": 0.78038335,
                  "_source": {
                    "DoctorList": "peter goh"
                  }
                }
              ]

Upvotes: 0

Related Questions