Skip to content

Instantly share code, notes, and snippets.

Created May 6, 2012 15:34
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 anonymous/e0512a077960469fca54 to your computer and use it in GitHub Desktop.
Save anonymous/e0512a077960469fca54 to your computer and use it in GitHub Desktop.
bool must behaviour
url:
http://localhost:9200/betadb/interaction/_search
Working query:
{
"sort": [
{
"interaction_date": "desc"
}
],
"query": {
"filtered": {
"query": {
"term": {
"body": "skierka"
}
},
"filter": {
"bool": {
"must":
{
"term": {
"operators": [
"35",
"12",
"51",
"55",
"14",
"29"
]
}
}
}
}
}
},
"from": "0",
"size": "50",
"fields": [
"interaction_id",
"last_updated","operators","labels"
]
}
Result:
{
"took": 52,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 7,
"max_score": null,
"hits": [
{
"_index": "betadb",
"_type": "interaction",
"_id": "45244",
"_score": null,
"fields": {
"last_updated": "2010-11-12T08:37:53",
"operators": "{29}",
"interaction_id": "45244",
"labels": "{1}"
},
"sort": [
1236588240000
]
},
{
"_index": "betadb",
"_type": "interaction",
"_id": "143994",
"_score": null,
"fields": {
"last_updated": "2010-11-16T12:59:37",
"operators": "{29}",
"interaction_id": "143994",
"labels": "{1}"
},
"sort": [
1236377241000
]
},
{
"_index": "betadb",
"_type": "interaction",
"_id": "45253",
"_score": null,
"fields": {
"last_updated": "2011-07-06T23:51:13",
"operators": "{29}",
"interaction_id": "45253",
"labels": "{1}"
},
"sort": [
1236338803000
]
},
{
"_index": "betadb",
"_type": "interaction",
"_id": "144024",
"_score": null,
"fields": {
"last_updated": "2011-07-06T23:51:14",
"operators": "{29}",
"interaction_id": "144024",
"labels": "{1}"
},
"sort": [
1236337767000
]
},
{
"_index": "betadb",
"_type": "interaction",
"_id": "45515",
"_score": null,
"fields": {
"last_updated": "2010-11-12T08:39:41",
"operators": "{29}",
"interaction_id": "45515",
"labels": "{1}"
},
"sort": [
1234428752000
]
},
{
"_index": "betadb",
"_type": "interaction",
"_id": "144073",
"_score": null,
"fields": {
"last_updated": "2011-07-06T23:51:18",
"operators": "{29}",
"interaction_id": "144073",
"labels": "{1}"
},
"sort": [
1234368038000
]
},
{
"_index": "betadb",
"_type": "interaction",
"_id": "144138",
"_score": null,
"fields": {
"last_updated": "2011-07-06T23:51:20",
"operators": "{29}",
"interaction_id": "144138",
"labels": "{1}"
},
"sort": [
1234358556000
]
}
]
}
}
Failing Query:
{
"sort": [
{
"interaction_date": "desc"
}
],
"query": {
"filtered": {
"query": {
"term": {
"body": "skierka"
}
},
"filter": {
"bool": {
"must":
{
"term": {
"operators": [
"35",
"12",
"51",
"55",
"14",
"19"
]
}
}
}
}
}
},
"from": "0",
"size": "50",
"fields": [
"interaction_id",
"last_updated","operators","labels"
]
}
Result:
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment