Skip to content

PhraseSuggestCollate needs a Params property to pass params to the collate query #2849

@tsquires

Description

@tsquires

NEST/ElasticSearch.Net 5.3
Elasticsearch 5.5

When running a collate query on a phrase suggester the json produced and sent to the server looks like this with the params object inside of the query object:

        "collate": {
          "query": {
            "inline": "{\"bool\":{\"must\":[{\"match\":{\"{{field-name}}\":{\"query\":\"{{suggestion}}\",\"type\":\"phrase\"}}}],\"filter\":[{\"nested\":{\"query\":{\"bool\":{\"filter\":[{\"term\":{\"listings.site-ids\":{\"value\":\"{{site-id}}\"}}},{\"term\":{\"listings.region-id\":{\"value\":\"{{region-id}}\"}}},{\"term\":{\"listings.industry-id\":{\"value\":\"{{industry-id}}\"}}}]}},\"path\":\"listings\"}},{\"bool\":{\"must_not\":[{\"exists\":{\"field\":\"private-ids\"}}]}}]}}}",
            "params": {
              "field-name": "name",
              "site-id": "1",
              "region-id": "1",
              "industry-id": "4"
            }
          },
          "prune": true
        }

While a working query when setting up the json manually looks like this with the params object inside of the collate object instead:

        "collate": {
        	"query": {
        		"inline": "{\"bool\":{\"must\":[{\"match\":{\"{{field-name}}\":{\"query\":\"{{suggestion}}\",\"type\":\"phrase\"}}}],\"filter\":[{\"nested\":{\"query\":{\"bool\":{\"filter\":[{\"term\":{\"listings.site-ids\":{\"value\":\"{{site-id}}\"}}},{\"term\":{\"listings.region-id\":{\"value\":\"{{region-id}}\"}}},{\"term\":{\"listings.industry-id\":{\"value\":\"{{industry-id}}\"}}}]}},\"path\":\"listings\"}},{\"bool\":{\"must_not\":[{\"exists\":{\"field\":\"private-ids\"}}]}}]}}"
        	},
        	"params": {
        		"field-name": "name",
        		"site-id": "1",
        		"region-id": "1",
        		"industry-id": "4"
        		},
        	"prune": true
        }

Steps to reproduce:

  1. Setup a phrase suggester in json with a collate query that takes parameters
  2. Setup the same phrase suggester in .Net
  3. Compare the request body of the .Net request to the json from Step 1 and see the params object is at the wrong level so in the .Net request the params are not replaced in the collate query

Adding a Params property to PhraseSuggestCollate fixes this and produces a working request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions