-
-
Save robfaraj/f8a124e09faf61cff35b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// No Term Provided | |
// | |
// SELECT id FROM type | |
// WHERE site_id IN (1,7) AND status_id=2 AND branch_id=1651 | |
// ORDER BY branch_id DESC | |
// | |
curl -XPOST 'http://localhost:9200/index/type/_search?pretty=true&fields=_id' -d ' | |
{ | |
"query" : { | |
"constant_score" : { | |
"filter" : { | |
"and" : [ | |
{ | |
"query" : { | |
"field": { | |
"site_id" : "1 OR 7" | |
} | |
} | |
}, | |
{ | |
"term": { | |
"status_id": 2 | |
} | |
}, | |
{ | |
"term": { | |
"branch_id": 1651 | |
} | |
} | |
] | |
} | |
} | |
}, | |
"sort" : [ | |
{ "branch_id" : {"reverse" : false} }, | |
"_score" | |
], | |
"facets" : { | |
"sites" : { | |
"terms" : { "field" : "type_id" } | |
}, | |
"status" : { | |
"terms" : { "field" : "status_id" } | |
} | |
} | |
} | |
' | |
// Term Provided | |
// | |
// SELECT id FROM type | |
// WHERE _all LIKE (%foobar%) AND site_id IN (1,7) AND status_id=2 AND branch_id=1651 | |
// ORDER BY branch_id DESC | |
// | |
curl -XPOST 'http://localhost:9200/index/type/_search?pretty=true&fields=_id' -d ' | |
{ | |
"query" : { | |
"filtered" : { | |
"query" : { | |
"query_string" : { | |
"query" : "foobar" | |
} | |
}, | |
"filter" : { | |
"and" : [ | |
{ | |
"query" : { | |
"field": { | |
"site_id" : "1 OR 7" | |
} | |
} | |
}, | |
{ | |
"term": { | |
"status_id": 2 | |
} | |
}, | |
{ | |
"term": { | |
"branch_id": 1651 | |
} | |
} | |
] | |
} | |
} | |
}, | |
"sort" : [ | |
{ "branch_id" : {"reverse" : true} }, | |
"_score" | |
], | |
"facets" : { | |
"sites" : { | |
"terms" : { "field" : "type_id" } | |
}, | |
"status" : { | |
"terms" : { "field" : "status_id" } | |
} | |
} | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Right, I didn't notice that. The one good thing about using
_source
instead of storing each field separately, is that it makes it easy to reindex your data when you decide to change your mapping, or you upgrade and something core has changed which requires reindexing._all
maps to all 8 fields - its includes all fields, exceptany which haveinclude_in_all
set tofalse
. The value ofstore
has no impact on inclusion in_all