Skip to content

Instantly share code, notes, and snippets.

@steeve
Created March 12, 2011 14:26
Show Gist options
  • Save steeve/867270 to your computer and use it in GitHub Desktop.
Save steeve/867270 to your computer and use it in GitHub Desktop.
:query => {
:filtered => {
:query => {
:query_string => {
#:default_operator => "AND",
:query => query,
},
},
:filter => {
:or => [
:and => [
{ :term => { :_type => "type1" } },
:or => [
{ :term => { :type1_param => true } },
{ :term => { :type1_param2 => 2 } },
],
],
:and => [
{ :term => { :_type => "type2" } },
:or => [
{ :prefix => { :type2_param => "foo" } },
{ :term => { :type2_param2 => 2 } },
]
],
],
}
},
},
@clintongormley
Copy link

curl -XGET 'http://127.0.0.1:9200/_all/_search' -d '
{
"query" : {
"filtered" : {
"filter" : {
"or" : [
{
"and" : [
{
"term" : {
"_type" : "type_1"
}
},
{
"or" : [
{
"term" : {
"type_1_param" : true
}
},
{
"term" : {
"type_1_param2" : 2
}
}
]
}
]
},
{
"and" : [
{
"term" : {
"_type" : "type_2"
}
},
{
"or" : [
{
"term" : {
"type_2_param" : "foo"
}
},
{
"term" : {
"type_2_param2" : 2
}
}
]
}
]
}
]
},
"query" : {
"query_string" : {
"query" : "foo bar baz"
}
}
}
}
}
'

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