AND query

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

AND query

paul
Hi ,

My Data:

{
   "programs":"Computer",
   degreesAwarded:[
      Bachelor,
      Certificate,
      Doctorate
   ],
   "costTution":22977,
   "isCoed":"Yes"
}


My Query:
I get results for below query 
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "programs": "Computer",
        }
      }
    }
  }
}

But i want to find something like   "programs": "Computer",  AND  "degreesAwarded":"Bachelor"  when i do that below i get exception ,
i could not find how to do a AND/OR query . 
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "programs": "Computer",
      "degreesAwarded":"Bachelor"
        }
      }
    }
  }
}


--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: AND query

paul
This worked for me 
{
   "query":{
      "bool":{
         "must":[
            {
               "match":{
                  "programs":"computer"
               }
            },
            {
               "match":{
                  "degreesAwarded":"Bachelor"
               }
            }
         ]
      }
   }
}

On Thursday, 21 November 2013 18:19:38 UTC+5:30, paul wrote:
Hi ,

My Data:

{
   "programs":"Computer",
   degreesAwarded:[
      Bachelor,
      Certificate,
      Doctorate
   ],
   "costTution":22977,
   "isCoed":"Yes"
}


My Query:
I get results for below query 
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "programs": "Computer",
        }
      }
    }
  }
}

But i want to find something like   "programs": "Computer",  AND  "degreesAwarded":"Bachelor"  when i do that below i get exception ,
i could not find how to do a AND/OR query . 
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "programs": "Computer",
      "degreesAwarded":"Bachelor"
        }
      }
    }
  }
}


--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: AND query

dadoonet
You should use filtered query I guess as your second clause sounds like to me as a filter!
Filters are cached.

--
David ;-)
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 21 nov. 2013 à 15:30, paul <[hidden email]> a écrit :

This worked for me 
{
   "query":{
      "bool":{
         "must":[
            {
               "match":{
                  "programs":"computer"
               }
            },
            {
               "match":{
                  "degreesAwarded":"Bachelor"
               }
            }
         ]
      }
   }
}

On Thursday, 21 November 2013 18:19:38 UTC+5:30, paul wrote:
Hi ,

My Data:

{
   "programs":"Computer",
   degreesAwarded:[
      Bachelor,
      Certificate,
      Doctorate
   ],
   "costTution":22977,
   "isCoed":"Yes"
}


My Query:
I get results for below query 
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "programs": "Computer",
        }
      }
    }
  }
}

But i want to find something like   "programs": "Computer",  AND  "degreesAwarded":"Bachelor"  when i do that below i get exception ,
i could not find how to do a AND/OR query . 
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "programs": "Computer",
      "degreesAwarded":"Bachelor"
        }
      }
    }
  }
}


--
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 [hidden email].
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: AND query

paul
Sure will look into filter query , thank you for the suggestion.

--
Paul

On Thursday, 21 November 2013 21:33:09 UTC+5:30, David Pilato wrote:
You should use filtered query I guess as your second clause sounds like to me as a filter!
Filters are cached.

--
David ;-)
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 21 nov. 2013 à 15:30, paul <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="i6veEwwG5GAJ">avinas...@...> a écrit :

This worked for me 
{
   "query":{
      "bool":{
         "must":[
            {
               "match":{
                  "programs":"computer"
               }
            },
            {
               "match":{
                  "degreesAwarded":"Bachelor"
               }
            }
         ]
      }
   }
}

On Thursday, 21 November 2013 18:19:38 UTC+5:30, paul wrote:
Hi ,

My Data:

{
   "programs":"Computer",
   degreesAwarded:[
      Bachelor,
      Certificate,
      Doctorate
   ],
   "costTution":22977,
   "isCoed":"Yes"
}


My Query:
I get results for below query 
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "programs": "Computer",
        }
      }
    }
  }
}

But i want to find something like   "programs": "Computer",  AND  "degreesAwarded":"Bachelor"  when i do that below i get exception ,
i could not find how to do a AND/OR query . 
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "programs": "Computer",
      "degreesAwarded":"Bachelor"
        }
      }
    }
  }
}


--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="i6veEwwG5GAJ">elasticsearc...@googlegroups.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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.