-
-
Save kimchy/995045 to your computer and use it in GitHub Desktop.
curl localhost:9200/_search -d '{ | |
"query" : { | |
"filtered" : { | |
"query" : {"match_all" : {}}, | |
"filter" : { | |
"and" : [ | |
{ | |
"range" : { | |
"file_size" : {"from" : 10, "to" : 10000} | |
} | |
}, | |
{ | |
"range" : { | |
"file_size" : {"from" : 10001, "to" : 1000001} | |
} | |
} | |
] | |
} | |
} | |
} | |
}' |
I'm trying to do multiple filters against a NESTED object. The keyword in the nested object is setup not_analyzed. It works great with one filter but once I add the other I get nothing back. What might I be doing wrong?
Here is the REST JSON code I'm using:
{
"query": {
"nested": {
"_scope": "productscope",
"path": "productkeywords",
"score_mode": "avg",
"query" : {
"filtered" : {
"query": { "match_all" : {} },
"filter" : {
"and" : [
{
"term" : {"productkeywords.keyword": "Wi-Fi" }
},
{
"term" : {"productkeywords.keyword": "Other" }
}
]
}
}
}
}
}
}
Here is an example of the JSON result that works:
{
"_index": "products",
"_type": "all",
"_id": "1005",
"_score": 1,
"_source":
{
"mktprodfamilytransid": 1005,
"name": "iDigi Telehealth Application Kit",
"descriptionhtml": "
The iDigi Telehealth Application Kit enables the creation of secure, highly scalable cloud-connected healthcare gateway solutions right out of the box. Based on the Freescale® Semiconductor Home Health Hub reference design, this kit brings wireless and wired connectivity to a wide array of healthcare devices and sensors. The iDigi® Device Cloud™ provides remote management and secure data integration capabilities, allowing customers to build innovative and connected telehealth solutions for the medical and healthcare market.
",
"teasertext": "
Includes Freescale Semiconductor Home Health Hub (HHH) reference design
Built-in iDigi Device Cloud™ services for anywhere, anytime information access
Integrated wired and wireless connectivity options
Microsoft Windows Emdedded Compact 7 and Linux BSP support included
",
"shortdescription": "Cloud-enabled Home Health Hub reference design",
"productkeywords":
[
{
"keywordcategoryid": 1,
"keywordcategory": "Frequency",
"keywordcategoryslug": "freq",
"keywordid": 6,
"keyword": "Other",
"keywordslug": "other"
},
{
"keywordcategoryid": 2,
"keywordcategory": "Wireless Products",
"keywordcategoryslug": "wireless",
"keywordid": 8,
"keyword": "Wi-Fi",
"keywordslug": "wifi"
},
{
"keywordcategoryid": 2,
"keywordcategory": "Wireless Products",
"keywordcategoryslug": "wireless",
"keywordid": 10,
"keyword": "ZigBee",
"keywordslug": "zigbee"
},
{
"keywordcategoryid": 3,
"keywordcategory": "Wired Connectivity",
"keywordcategoryslug": "wired",
"keywordid": 13,
"keyword": "Ethernet",
"keywordslug": "ethernet"
},
{
"keywordcategoryid": 3,
"keywordcategory": "Wired Connectivity",
"keywordcategoryslug": "wired",
"keywordid": 15,
"keyword": "Serial",
"keywordslug": "serial"
}
]
}
}
I'm trying to do multiple filters against a NESTED object. The keyword in the nested object is setup not_analyzed. It works great with one filter but once I add the other I get nothing back. What might I be doing wrong?
Here is the REST JSON code I'm using:
{
"query": {
"nested": {
"_scope": "productscope",
"path": "productkeywords",
"score_mode": "avg",
"query" : {
"filtered" : {
"query": { "match_all" : {} },
"filter" : {
"and" : [
{
"term" : {"productkeywords.keyword": "Wi-Fi" }
},
{
"term" : {"productkeywords.keyword": "Other" }
}
]
}
}
}
}
}
}
Here is an example of the JSON result that works:
The iDigi Telehealth Application Kit enables the creation of secure, highly scalable cloud-connected healthcare gateway solutions right out of the box. Based on the Freescale® Semiconductor Home Health Hub reference design, this kit brings wireless and wired connectivity to a wide array of healthcare devices and sensors. The iDigi® Device Cloud™ provides remote management and secure data integration capabilities, allowing customers to build innovative and connected telehealth solutions for the medical and healthcare market.
",
"teasertext": "
",
"shortdescription": "Cloud-enabled Home Health Hub reference design",
"productkeywords":
[
{
"keywordcategoryid": 1,
"keywordcategory": "Frequency",
"keywordcategoryslug": "freq",
"keywordid": 6,
"keyword": "Other",
"keywordslug": "other"
},
{
"keywordcategoryid": 2,
"keywordcategory": "Wireless Products",
"keywordcategoryslug": "wireless",
"keywordid": 8,
"keyword": "Wi-Fi",
"keywordslug": "wifi"
},
{
"keywordcategoryid": 2,
"keywordcategory": "Wireless Products",
"keywordcategoryslug": "wireless",
"keywordid": 10,
"keyword": "ZigBee",
"keywordslug": "zigbee"
},
{
"keywordcategoryid": 3,
"keywordcategory": "Wired Connectivity",
"keywordcategoryslug": "wired",
"keywordid": 13,
"keyword": "Ethernet",
"keywordslug": "ethernet"
},
{
"keywordcategoryid": 3,
"keywordcategory": "Wired Connectivity",
"keywordcategoryslug": "wired",
"keywordid": 15,
"keyword": "Serial",
"keywordslug": "serial"
}
]
}
}