【问题标题】:ElasticSearch: how to mix terms query with wildcardElasticSearch:如何将术语查询与通配符混合
【发布时间】:2012-11-09 01:10:03
【问题描述】:

假设,我有以下查询:“文档电子表格应用程序*”。我想构建相当于这种查询'_search?q=_all:document+spreadsheet+app*'的查询字典。比如说,query_words_list = ['document', 'spreadsheet', 'app']。我试过这个:

{
  'query': {
     'terms': {
        '_all': query_words_list[:-1] + [query_words_list[-1] + '*'],
     }
   }
}

但是,如果您比较两个查询的结果,它们是不等价的。任何提示相当于 '_search?q=_all:document+spreadsheet+app*' 的查询字典看起来像什么?提前致谢!

【问题讨论】:

    标签: search lucene wildcard elasticsearch


    【解决方案1】:

    【讨论】:

    • 谢谢!实际上,我最终在 should 子句中使用多个术语查询(最后一个术语是通配符)构建了 bool 查询。
    猜你喜欢
    • 2022-01-14
    • 1970-01-01
    • 1970-01-01
    • 2021-11-11
    • 1970-01-01
    • 2016-05-15
    • 2019-12-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多