Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Elasticsearch cross_字段所有术语必须至少出现在on字段中_Search_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Full Text Search - Fatal编程技术网 elasticsearch,full-text-search,Search,elasticsearch,Full Text Search" /> elasticsearch,full-text-search,Search,elasticsearch,Full Text Search" />

Elasticsearch cross_字段所有术语必须至少出现在on字段中

Elasticsearch cross_字段所有术语必须至少出现在on字段中,search,elasticsearch,full-text-search,Search,elasticsearch,Full Text Search,我想构建一个Elasticsearch查询,其中我查询多个字段,所有字段必须至少出现在一个字段中。我使用multi\u match查询cross\u字段 例如: 我的搜索是在用户对象上进行的,如: { firstname: '...', lastname: '...', email: '...' } 我们有2个用户: { firstname: 'Delphine', lastname: 'Dorémi', email: 'tyrell@interne.fr' } { firs

我想构建一个Elasticsearch查询,其中我查询多个字段,所有字段必须至少出现在一个字段中。我使用
multi\u match
查询
cross\u字段

例如:

我的搜索是在用户对象上进行的,如:

{ firstname: '...', lastname: '...', email: '...' }
我们有2个用户:

{
  firstname: 'Delphine',
  lastname: 'Dorémi',
  email: 'tyrell@interne.fr'
}

{
  firstname: 'Philippe',
  lastname: 'Mifasol',
  email: 'roybatty@interne.com'
}
询问:“雷切尔·米法索”

我想要的结果:没有结果(因为“Philippe”用户对象中缺少“Rachel”)

Elasticsearch实际给我的结果是:“Philippe”(我想是因为“Mifasol”匹配…)

这里是我的Elasticsearch查询:

query: {
  multi_match: {
    query: 'Rachel Mifasol',
    type: 'cross_fields',
    fields: ['firstname', 'lastname', 'emails'],
    operator: 'and'
  }
}
这里是我的分析器和映射:

settings: {
  analysis: {
    filter: {
      nGram_filter: {
        type: 'nGram',
          min_gram: 2,
          max_gram: 20,
          token_chars: [
          'letter',
          'digit',
          'punctuation',
          'symbol'
        ]
      }
    },
    analyzer: {
      nGram_analyzer: {
        type: 'custom',
          tokenizer: 'whitespace',
          filter: [
          'lowercase',
          'asciifolding',
          'nGram_filter'
        ]
      },
      whitespace_analyzer: {
        type: 'custom',
          tokenizer: 'whitespace',
          filter: [
          'lowercase',
          'asciifolding'
        ]
      }
    }
  }
},
mappings: {
  users: {
    properties: {
      firstname: {
        type: 'string',
          index_analyzer: 'nGram_analyzer',
          search_analyzer: 'whitespace_analyzer',
          fields: {
          sort: {
            type: 'string',
            index: 'not_analyzed'
          }
        }
      },
      lastname: {
        type: 'string',
          index_analyzer: 'nGram_analyzer',
          search_analyzer: 'whitespace_analyzer'
      },
      emails: {
        type: 'string',
          index_analyzer: 'nGram_analyzer',
          search_analyzer: 'whitespace_analyzer'
      }
    }
  }
}

你确定这个查询没有得到任何结果吗?我的应用程序执行这个查询(一个单词数组):查询:{multi_match:{query:['Rachel','Mifasol'],键入:'cross_fields',fields:['firstname','lastname','emails'],operator:'and'}这就是我得到结果的原因。。。所以我的问题是个错误。对不起,你明白了吗?我的问题是个错误。我发送给ES的查询是['Rachel','Mifasol',],而不是'Rachel Mifasol'。