Getting specific Fields

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

Getting specific Fields

paul
My DATA
---------------
{
   "rankingList":[
      {
         "value":9,
         "key":"Academic"
      },
      {
         "value":6,
         "key":"Flexibility"
      }
   ]
}

{
   "rankingList":[
      {
         "value":12,
         "key":"Academic"
      },
      {
         "value":6,
         "key":"Flexibility"
      }
   ]
}

My Mapping
-------------------
{
   "mappings":{
      "TestNested":{
         "properties":{
            "rankingList":{
               "type":"nested"
            }
         }
      }
   }
}

My QUERY
-----------------
{
  "query": {
    "nested": {
      "path": "rankingList",
      "query": {
        "bool": {
          "must": [
            {
              "match": {
                "rankingList.key": {
                  "query": "Academic"
                }
              }
            },
            {
              "range": {
                "rankingList.value": {
                  "gt": 5
                }
              }
            }
          ]
        }
      }
    }
  }
}

I want to get only the key value that is related to "Academic" within the array is it possible. right now query works fine but returns all the array elements.

- Paul

--
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].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/6f5c2cd1-a92e-4c8c-8bd3-ca8193033080%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Getting specific Fields

Ivan Brusic


On Thu, Jan 2, 2014 at 4:27 AM, paul <[hidden email]> wrote:
My DATA
---------------
{
   "rankingList":[
      {
         "value":9,
         "key":"Academic"
      },
      {
         "value":6,
         "key":"Flexibility"
      }
   ]
}

{
   "rankingList":[
      {
         "value":12,
         "key":"Academic"
      },
      {
         "value":6,
         "key":"Flexibility"
      }
   ]
}

My Mapping
-------------------
{
   "mappings":{
      "TestNested":{
         "properties":{
            "rankingList":{
               "type":"nested"
            }
         }
      }
   }
}

My QUERY
-----------------
{
  "query": {
    "nested": {
      "path": "rankingList",
      "query": {
        "bool": {
          "must": [
            {
              "match": {
                "rankingList.key": {
                  "query": "Academic"
                }
              }
            },
            {
              "range": {
                "rankingList.value": {
                  "gt": 5
                }
              }
            }
          ]
        }
      }
    }
  }
}

I want to get only the key value that is related to "Academic" within the array is it possible. right now query works fine but returns all the array elements.

- Paul

--
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].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/6f5c2cd1-a92e-4c8c-8bd3-ca8193033080%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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQDqTQy6iVe_%3DgSQowUE-Gh5Ug%2Bn2b_Jn2CsDeRN3GwGKA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Getting specific Fields

paul
Thank you for the quick response.


On Fri, Jan 3, 2014 at 1:00 AM, Ivan Brusic <[hidden email]> wrote:


On Thu, Jan 2, 2014 at 4:27 AM, paul <[hidden email]> wrote:
My DATA
---------------
{
   "rankingList":[
      {
         "value":9,
         "key":"Academic"
      },
      {
         "value":6,
         "key":"Flexibility"
      }
   ]
}

{
   "rankingList":[
      {
         "value":12,
         "key":"Academic"
      },
      {
         "value":6,
         "key":"Flexibility"
      }
   ]
}

My Mapping
-------------------
{
   "mappings":{
      "TestNested":{
         "properties":{
            "rankingList":{
               "type":"nested"
            }
         }
      }
   }
}

My QUERY
-----------------
{
  "query": {
    "nested": {
      "path": "rankingList",
      "query": {
        "bool": {
          "must": [
            {
              "match": {
                "rankingList.key": {
                  "query": "Academic"
                }
              }
            },
            {
              "range": {
                "rankingList.value": {
                  "gt": 5
                }
              }
            }
          ]
        }
      }
    }
  }
}

I want to get only the key value that is related to "Academic" within the array is it possible. right now query works fine but returns all the array elements.

- Paul

--
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].

--
You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/t6ebGDRVR3g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQDqTQy6iVe_%3DgSQowUE-Gh5Ug%2Bn2b_Jn2CsDeRN3GwGKA%40mail.gmail.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].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAO066G38R6iHcp7VHO-9T%3DtV0QtZoCxjPmYeP1-Ps2PLUsaojQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.