You are better of using a proper boolean filter for better performance.
Queries cannot be cached and query string query analyzes the terms. Here is
an example of your filter with a nested bool (should) filter:
"filter": {
"and": {
"filters": [
{
"bool": {
"must": [
{
"bool": {
"should": [
{
"term": {
"state": "MA"
}
},
{
"term": {
"state": "NY"
}
}
]
}
},
{
"range": {
"costOutofstateTution": {
"gte": 0,
"lte": 30000
}
}
}
]
}
}
]
}
}
Cheers,
Ivan
On Mon, Dec 30, 2013 at 10:03 PM, paul <[email protected]> wrote:
> I got the query wotking by using
>
> {
> "query_string": {
> "default_field": "state",
> "query": "MA NY"
> }
> }
>
> - Paul
>
> On Tuesday, 31 December 2013 11:07:06 UTC+5:30, paul wrote:
>>
>> My query is as below , which gives me all the colleges with state code
>> "MA" i want all the colleges that are in "MA" or "NY" how to add OR filter
>>
>> {
>> "query": {
>> "filtered": {
>> "query": {
>> "nested": {
>> "path": "programs",
>> "query": {
>> "bool": {
>> "must": [
>> {
>> "match": {
>> "programs.progName": "Computer and Information
>> Sciences"
>> }
>> },
>> {
>> "range": {
>> "programs.Bachelor": {
>> "gt": 0
>> }
>> }
>> }
>> ]
>> }
>> }
>> }
>> },
>> "filter": {
>> "and": {
>> "filters": [
>> {
>> "bool": {
>> "must": [
>> {
>> "term": {
>> "state": "MA"
>> }
>> },
>> {
>> "range": {
>> "costOutofstateTution": {
>> "gte": 0,
>> "lte": 30000
>> }
>> }
>> }
>> ]
>> }
>> }
>> ]
>> }
>> }
>> }
>> }
>> }
>>
> --
> You received this message because you are subscribed to the Google Groups
> "elasticsearch" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/d23102f3-3180-4cdc-9d51-8ca960c7bcd0%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQC5FF-F%3DLJzpsVUvcq1n%2B%2B_9DFcKgRFJ0r%3Dv3SS7jX_tQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.