Query into query


(pere roca ristol) #1

i have this query that works

"query": {"query_string" :{ "fields" : ["family"], "query": "Apocynaceae
Gentianaceae", "default_operator" : "OR" } }

i want to use it inside another query (see other query below), so that I
get the request that fit both filters.

I tried many different options ('filtered' and 'filter', put one query
inside other query...) without success. Any help for a elasticsearch
beginner?

thanks in advance,

curl -XGET
http://my_server:9200/idx_occurrence/Occurrence/_search?pretty=true -d '

{

"from" : 0, "size" : 10,

"query":

{

"bool" : {

  "must" : {

    "bool" : {

      "should" : {

        "bool" : {

          "must" : {

            "bool" : {

              "must" : [ {

                "range" : {

                  "decimalLatitude_interpreted" : {

                    "from" : 47,

                    "to" : 49,

                    "include_lower" : true,

                    "include_upper" : true

                  }

                }

              }, {

                "range" : {

                  "decimalLongitude_interpreted" : {

                    "from" : 6.9425781,

                    "to" : 7.790039,

                    "include_lower" : true,

                    "include_upper" : true

                  }

                }

              } ]

            }

          }

        }

      }

    }

  }

}

}

}'

--


(pere roca ristol) #2

ok, i finally managed to get it work. Something like...

"query" : {
"filtered":
{
"query":
{
"query_string":
{
"fields" : ["family"], "query": "Apocynaceae Gentianaceae"",
"default_operator" : "AND"
}
}
,
"filter":
{
"query" : {
"bool" : {
..........

On Wednesday, 19 September 2012 13:32:42 UTC+2, pere roca ristol wrote:

i have this query that works

"query": {"query_string" :{ "fields" : ["family"], "query": "Apocynaceae
Gentianaceae", "default_operator" : "OR" } }

i want to use it inside another query (see other query below), so that I
get the request that fit both filters.

I tried many different options ('filtered' and 'filter', put one query
inside other query...) without success. Any help for a elasticsearch
beginner?

thanks in advance,

curl -XGET
http://my_server:9200/idx_occurrence/Occurrence/_search?pretty=true -d '

{

"from" : 0, "size" : 10,

"query":

{

"bool" : {

  "must" : {

    "bool" : {

      "should" : {

        "bool" : {

          "must" : {

            "bool" : {

              "must" : [ {

                "range" : {

                  "decimalLatitude_interpreted" : {

                    "from" : 47,

                    "to" : 49,

                    "include_lower" : true,

                    "include_upper" : true

                  }

                }

              }, {

                "range" : {

                  "decimalLongitude_interpreted" : {

                    "from" : 6.9425781,

                    "to" : 7.790039,

                    "include_lower" : true,

                    "include_upper" : true

                  }

                }

              } ]

            }

          }

        }

      }

    }

  }

}

}

}'

--


(system) #3