Skip to content

Instantly share code, notes, and snippets.

@shikaiwen
Last active December 1, 2016 08:29
Show Gist options
  • Save shikaiwen/6f90a102436e4b52ef88c78d56454d97 to your computer and use it in GitHub Desktop.
Save shikaiwen/6f90a102436e4b52ef88c78d56454d97 to your computer and use it in GitHub Desktop.
Elasticsearch查询json
//最简单的查询
{
"from": 0,
"size": 10000,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"should": { "term": { "fhId": "614" }}
//"should": {"term":{"fhId":"3257030"}}
}
}
}
}
}
{
// sort 排序用
"sort": [
{
"rentRankScore": "desc"
}
],
//设置查询的记录,可用来分页
"from": 0, "size": 20,
"query": {
"filtered": {
"query": {
"match_all":{}
//也可以在这里设置条件 "bool": {
//"must": { "match": { "areaName": "宝安" }}}
//}
},
"filter": {
"range": {
"rentRankScore":{ "gte":10, "lt":80 }
}
}
}
}
}
//只查询指定字段
{
"_source": {
"include": [
"fhId",
"saleRankScore",
"rentRankScore"
]
},
"sort": [
{
"rentRankScore": "desc"
}
],
"from": 0,
"size": 924,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
}
}
}
}
//查询多个指定房源
{
"_source": {
"include": [
"fhId",
"saleRankScore",
"rentRankScore"
]
},
"sort": [
{
"rentRankScore": "desc"
}
],
"from": 0,
"size": 10000,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"should": { "term": { "fhId": "1583679" }},
"should": {"term":{"fhId":"3257030"}}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment