-
Notifications
You must be signed in to change notification settings - Fork 488
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
[DOC]Search templates loop works wrong #5054
Comments
@SonaGharibyan Can you try passing 1 and 2 as strings: |
@kolchfa-aws Yes sorry regarding "params" it was a typo I've updated it. And I've also tried to pass "source" as a string parameter and it also returns all the values where "team" filed (in this example) is empty string (""). {
"source": "{\"query\":{\"terms\":{\"team\":[\"{{#myTeams}}\",\"{{.}}\",\"{{/myTeams}}\"]}}}",
"params": {
"myTeams": ["Team A", "Team C"]
}
} |
@SonaGharibyan Mustache inserts a comma after every array element so you're getting a match on a phantom empty element produced by a comma after the last term. To avoid this problem, run the query as follows:
|
@kolchfa-aws but I also need to add extra elements like "3" here {
"source":{
"query":{
"bool":{
"filter":[
{
"terms":{
"field":["{{#names}}","{{.}}","{{/names}}","3"]
}
}
]
}
}
},
"params":{
"names":["1", "2"]
}
} |
Can you just include "3" as an element of the |
@kolchfa-aws no, in my case this two data are coming from different places and I don't have access to names array. |
@opensearch-project/opensearch-core Could someone take a look at this issue please? Thanks! |
What do you want to do?
Tell us about your request. Provide a summary of the request and all versions that are affected.
Having issues with using search templates loops https://opensearch.org/docs/latest/search-plugins/search-template/#loops
I have this query
which should return items where "field" equals to "1", "2" or "3". But it also return items where "field" is to empty string ("").
Is there another way to destruct "names" array?
pls update docs accordingly
What other resources are available? Provide links to related issues, POCs, steps for testing, etc.
Found similar question just from Elastic Search -> https://stackoverflow.com/questions/67590223/how-to-pass-array-to-elasticsearch-search-template-using-mustache
The text was updated successfully, but these errors were encountered: