简体   繁体   中英

ElasticSearch Source Filtering does not Always Work with Multi Search JavaScript/Node API

The source filtering feature of ElasticSearch 2.3 does not always work when used with multi search (msearch) in JavaScript/Node API. I tried different combinations like _sourceInclude, _source_include, _source: {include: 'specificField'}, and also ['specificField'] instead of 'specificField'.

Any clue?

params.searches = [ { _type: 'Doc', _source: 'specificField' }, {query: {constant_score: {filter: {bool: {must: [ {term: {id: params.id}}, {term: {anotherField: false}} ]}}}}}, ];

The source should be specified along with the query and not with the index and type

Example :

params.searches = [
    {"index":"test", "_type":"Doc"},
    {
     "_source": [
         "specificField"
      ],
     "query": {
       "constant_score": {
        "filter": {
          "bool": {
           "must": [
            {
              "term": {
                "id": "params.id"
              }
            },
            {
              "term": {
                "anotherField": "false"
              }
            }
          ]
        }
      }
    }
  }
  }
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM