Can I specify the result fields in elasticsearch query?

前端 未结 2 1144
小鲜肉
小鲜肉 2020-12-15 08:36

In my dataset, a document contains 20+ fields with nested objects. Most of them are long text fields. These fields are important for full-text search but we only need to sho

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-15 09:16

    Take care in ElasticSearch 1.0.0.RC1 the fields return values now are always lists, if need the result to be a long instead of a list of longs (which might be a single value list for you most of the time) you can limit those with _source

    {"_source" : ["field1", "field2", ...],
         "query" : {
            "term" : { "user" : "kimchy" }
        }
    }
    

提交回复
热议问题