简体   繁体   English

Elasticsearch匹配除指定字段之外的所有查询,排除

[英]Elasticsearch match all except specified fields query, exclude

My indexed Elasticsearch documents include many fields. 我编入索引的Elasticsearch文档包含许多字段。 I've been using match_all query to get results. 我一直在使用match_all查询来获取结果。 There are a few fields I'd like to exclude from match_all, is this possible? 我想从match_all中排除一些字段,这可能吗?

For this question I will give you the example 对于这个问题,我会举一个例子

GET index_name/index_type/_search
{
  "_source": {

  "exclude": [
    ]
  },
  "query": {
    "match_all": {}
  }
}

In Elasticsearch you can use partial fields to filter fields. 在Elasticsearch中,您可以使用部分字段来过滤字段。

Example: 例:

{
    "query": {
        "match_all": {}
    },
    "partial_fields": {
        "partial1": {
            "exclude": ["excludeField1", "excludeField2"]
        }
    }
}

With ElasticSearch 2.x, you can use source filtering , example: 在ElasticSearch 2.x中,您可以使用源过滤 ,例如:

{
    "_source": {
        "include": [ "obj1.*", "obj2.*" ],
        "exclude": [ "*.description" ]
    },
    "query" : {
        "term" : { "user" : "kimchy" }
    }
}

For a GET request you may also pass it via the url . 对于GET请求,您也可以通过url传递它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在嵌套对象的所有字段上进行弹性搜索嵌套查询以匹配 - Making an elasticsearch nested query for match on all fields of nested object 在任何情况下,Elasticsearch是否都使用delete_by_query删除所有文档,除非查询说全部匹配? - Does Elasticsearch deletes all documents using delete_by_query, in any case, except query says match all? 如何在Elasticsearch中使用_all字段查询所有字段之间的文本? - How to query a text among all fields except using _all field in elasticsearch? Elasticsearch查询match_all - Elasticsearch Query match_all Elasticsearch 在所有字段上多匹配精确短语 - Elasticsearch multi match exact phrase on all fields 在 Elasticsearch 的所有字段中按完全匹配搜索 - Search by exact match in all fields in Elasticsearch ElasticSearch:对所有字段使用match_phrase - ElasticSearch: Using match_phrase for all fields Elasticsearch:对嵌套字段的多重匹配查询 - Elasticsearch : Multi match query on nested fields ElasticSearch查询仅在所有字段都与我的过滤器匹配时才检索结果? - ElasticSearch query to retrieve results only when all fields match my filter? Elasticsearch突出显示:使用“ copy_to”创建的自定义“ _all”字段上的“多重匹配”查询 - Elasticsearch highlighting: “multi-match” query on custom “_all”-fields created with “copy_to”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM