Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tsquires opened this issue Sep 8, 2017 · 1 comment

Comments

@tsquires
Copy link

tsquires commented Sep 8, 2017

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.

@russcam
Copy link
Contributor

russcam commented Dec 18, 2017

Thanks for opening @tsquires; apologies it's taken a while to respond. Looking at this now

russcam added a commit that referenced this issue Dec 18, 2017
PhraseSuggestCollate Query takes an ITemplateQuery that allows the specification of parameters. The API of phrase suggester however specifies the parameters for the query at the same level as the query, not nested within the query object. This commit adds a Parameters dictionary to IPhraseSuggestCollate so that parameters are serialized to the correct query form. If parameters are specified on the ITemplateQuery, these are assigned to the parameters on IPhraseSuggestCollate.

Add XML documentation to indicate the usage of each property.

Closes #2849
russcam added a commit that referenced this issue Dec 21, 2017
PhraseSuggestCollate Query takes an ITemplateQuery that allows the specification of parameters. The API of phrase suggester however specifies the parameters for the query at the same level as the query, not nested within the query object. This commit adds a Parameters dictionary to IPhraseSuggestCollate so that parameters are serialized to the correct query form. If parameters are specified on the ITemplateQuery, these are assigned to the parameters on IPhraseSuggestCollate.

Add XML documentation to indicate the usage of each property.

Closes #2849
russcam added a commit that referenced this issue Dec 21, 2017
This commit adds a Parameters dictionary to IPhraseSuggestCollate so that parameters are serialized to the correct query form and introduces a PhraseSuggestCollateQuery to specify the query.

Add XML documentation to indicate the usage of each property.

Closes #2849

(cherry-picked from commit f905270)
russcam added a commit that referenced this issue Dec 21, 2017
PhraseSuggestCollate Query takes an IScript that allows the specification of parameters. The API of phrase suggester however specifies the parameters for the query at the same level as the query, not nested within the query object. This commit adds a Parameters dictionary to IPhraseSuggestCollate so that parameters are serialized to the correct query form. If parameters are specified on the IScript, these are assigned to the parameters on IPhraseSuggestCollate.

Add XML documentation to indicate the usage of each property.

Closes #2849

(cherry picked from commit f905270)
@russcam russcam added the v2.4.7 label Dec 21, 2017
russcam added a commit that referenced this issue Dec 22, 2017
* Add Params to PhraseSuggestCollate

This commit adds a Parameters dictionary to IPhraseSuggestCollate so that parameters are serialized to the correct query form and introduces a PhraseSuggestCollateQuery to specify the query.

Add XML documentation to indicate the usage of each property.

Closes #2849

(cherry-picked from commit f905270)

* Deprecate all usages of TemplateQuery

Now that Phrase suggester no longer uses TemplateQuery, deprecate the interface, object initializer and fluent descriptor of template query
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants