简体   繁体   中英

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".

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"
                  }
                }
              ]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM