Skip to content

Instantly share code, notes, and snippets.

@shoteff
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shoteff/20fa2411ede09068ce95 to your computer and use it in GitHub Desktop.
Save shoteff/20fa2411ede09068ce95 to your computer and use it in GitHub Desktop.
Works as expected because of "lenient : true"
{
"query":
{
"bool":
{
"should":
[
{
"simple_query_string":
{
"query": "this",
"fields":
[
"id",
"title"
],
"default_operator": "and",
"lenient": true
}
}
]
}
}
}
------------------------------------------------------------------
No results found, no errors - searching in non-existing fields
{
"query":
{
"bool":
{
"should":
[
{
"simple_query_string":
{
"query": "this",
"fields":
[
"id.nonexisting",
"title.nonexisting"
],
"default_operator": "and"
}
}
]
}
}
}
-----------------------Possible bug here----------------------------
If I combine both queries it doesn't work - no errors, but no results (wrong as I have "should" clause,
"minimum_should_match" is 1 by default, and the 1st query should yeld results)
{
"query":
{
"bool":
{
"should":
[
{
"simple_query_string":
{
"query": "this",
"fields":
[
"id",
"title"
],
"default_operator": "and",
"lenient": true
}
},
{
"simple_query_string":
{
"query": "this",
"fields":
[
"id.nonexisting",
"title.nonexisting"
],
"default_operator": "and"
}
}
]
}
}
}
------------------------------------------------------------------
I'm only removing the integer "id" field from the first subquery and it works
{
"query":
{
"bool":
{
"should":
[
{
"simple_query_string":
{
"query": "this",
"fields":
[
"title"
],
"default_operator": "and",
"lenient": true
}
},
{
"simple_query_string":
{
"query": "this",
"fields":
[
"id.nonexisting",
"title.nonexisting"
],
"default_operator": "and"
}
}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment