Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mrvisser
Last active August 29, 2015 14:03
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 mrvisser/3db551b84baff0085eaf to your computer and use it in GitHub Desktop.
Save mrvisser/3db551b84baff0085eaf to your computer and use it in GitHub Desktop.
query: {
"query": {
"filtered": {
"query": {
"bool": {
"should": [
{
"multi_match": {
"fields": [
"q_high^2.0",
"q_low^0.75"
],
"query": "index-without-full-content-item",
"boost": 5
}
},
{
"has_child": {
"type": "content_comment",
"query": {
"multi_match": {
"fields": [
"body"
],
"query": "index-without-full-content-item"
}
},
"score_type": "max"
}
}
],
"minimum_should_match": 1
}
},
"filter": {
"and": [
{
"and": [
{
"term": {
"_type": "resource"
}
},
{
"terms": {
"resourceType": [
"content"
]
}
}
]
},
{
"or": [
{
"and": [
{
"or": [
{
"term": {
"visibility": "public"
}
},
{
"and": [
{
"term": {
"tenantAlias": "camtest"
}
},
{
"or": [
{
"term": {
"visibility": "loggedin"
}
},
{
"and": [
{
"term": {
"resourceType": "group"
}
},
{
"terms": {
"joinable": [
"yes",
"request"
]
}
}
]
}
]
}
]
}
]
},
{
"term": {
"tenantAlias": "camtest"
}
}
]
},
{
"has_child": {
"type": "resource_members",
"query": {
"or": [
{
"terms": {
"direct_members": [
"u:camtest:eyZvfPLPdxe"
]
}
},
{
"terms": {
"direct_members": [
"resource_memberships",
"u:camtest:eyZvfPLPdxe#resource_memberships#",
"direct_memberships"
]
}
}
]
}
}
}
]
}
]
}
}
},
"size": 1,
"sort": [
{
"_score": {
"order": "desc"
}
},
{
"sort": "asc"
}
],
"min_score": 0.2,
"fields": "*"
}
query: {
"query": {
"filtered": {
"query": {
"bool": {
"should": [
{
"multi_match": {
"fields": [
"q_high^2.0",
"q_low^0.75"
],
"query": "index-without-full-content-item",
"boost": 5
}
},
{
"has_child": {
"type": "content_comment",
"query": {
"multi_match": {
"fields": [
"body"
],
"query": "index-without-full-content-item"
}
},
"score_type": "max"
}
}
],
"minimum_should_match": 1
}
},
"filter": {
"and": [
{
"and": [
{
"term": {
"_type": "resource"
}
},
{
"terms": {
"resourceType": [
"content"
]
}
}
]
},
{
"or": [
{
"and": [
{
"or": [
{
"term": {
"visibility": "public"
}
},
{
"and": [
{
"term": {
"tenantAlias": "camtest"
}
},
{
"or": [
{
"term": {
"visibility": "loggedin"
}
},
{
"and": [
{
"term": {
"resourceType": "group"
}
},
{
"terms": {
"joinable": [
"yes",
"request"
]
}
}
]
}
]
}
]
}
]
},
{
"term": {
"tenantAlias": "camtest"
}
}
]
},
{
"or": [
{
"has_child": {
"type": "resource_members",
"query": {
"terms": {
"direct_members": [
"u:camtest:eyZpojPDOxx"
]
}
}
}
},
{
"has_child": {
"type": "resource_members",
"query": {
"terms": {
"direct_members": [
"resource_memberships",
"u:camtest:eyZpojPDOxx#resource_memberships#",
"direct_memberships"
]
}
}
}
}
]
}
]
}
]
}
}
},
"from": 1,
"size": 25,
"sort": [
{
"_score": {
"order": "desc"
}
},
{
"sort": "asc"
}
],
"min_score": 0.2,
"fields": "*"
}
@mrvisser
Copy link
Author

In these 2 ElasticSearch queries, one is an OR filter that wraps 2 has_child queries, and the other is a has_child query that has an internal OR filter on the terms (the direct_members ones). Is one expected to perform different than the other?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment