- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
因此,我正在建立一个索引,我想进行一次搜索,即可对一个字段进行部分单词edge_ngram
搜索,而对其余字段进行更常规的搜索。据我了解,仅通过匹配_all
就可以轻松做到这一点。但是我似乎无法使其工作。
我已经能够通过bool
查询获得期望的结果,该查询分别搜索_all
和特定的ngram字段,但这似乎是hackey,我想我只是缺少了一些简单的东西。
这只是一个最小的示例,以显示我在做什么以及它对我不起作用。
这是索引设置:
curl -XPUT "http://localhost:9200/test_index?pretty=true" -d'
{
"settings": {
"analysis": {
"filter": {
"edge_ngram_filter": {
"type": "edge_ngram",
"min_gram": 2,
"max_gram": 20
}
},
"analyzer": {
"edge_ngram_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"edge_ngram_filter"
]
}
}
}
},
"mappings": {
"doc": {
"properties": {
"text_field": {
"type": "string",
"analyzer": "edge_ngram_analyzer",
"search_analyzer": "standard"
}
}
}
}
}'
curl -XPUT "http://localhost:9200/test_index/doc/1?pretty=true" -d'
{
"text_field": "Hello, World!"
}'
curl -XPOST "http://localhost:9200/test_index/_search?pretty=true" -d'
{
"query": {
"match": {
"_all": "hell"
}
}
}'
curl -XPOST "http://localhost:9200/test_index/_search?pretty=true" -d'
{
"query": {
"match": {
"_all": "hello"
}
}
}'
curl -XPOST "http://localhost:9200/test_index/_search?pretty=true" -d'
{
"query": {
"match": {
"text_field": "hell"
}
}
}'
curl -XGET "http://localhost:9200/test_index/doc/1/_termvector?fields=text_field&pretty=true"
Version: 2.3.3, Build: 218bdf1/2016-05-17T15:40:04Z, JVM: 1.8.0_92
4.4.3-1-custom
最佳答案
_all
字段将所有字段的原始值组合为字符串,而不是为每个字段生成的术语。因此,在您的情况下,它不包含edge_ngram_analyzer
生成的术语,仅包含text_field
字段中的文本。就像任何其他文本字段一样,您可以为其指定分析器,等等。在您的示例中,它使用的是默认分析器。
关于elasticsearch - 无法查询_all中的edge_ngram字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37958011/
我刚刚开始学习elasticsearch,想知道我从elasticsearch website复制的以下句子中的术语和值之间的区别是什么: "It is important to note that
我嵌套,您如何产生此请求: GET demo_covariant/_all/2 最佳答案 client.Get(2, g => g .Index("demo_covariant") .
我想从elasticsearch的“_all”字段中删除所有数字和日期。这样可以减小尺寸并提高性能。我以为可以通过使用dynamic_templates完成此操作,但我无法使其正常工作。 映射是这样的
我没有得到 THIS示例为什么以下两个查询返回 12 作为结果计数?帖子解释说数据在 _all 中的索引方式是不同的。但它并没有解释它。有人可以帮我理解这一点。 GET /_search?q=2014
我是Elasticsearch的新手。我们需要索引和检索具有不同数据类型的某些数据。我们正在使用自定义“_all”字段,如以下链接中所述 Custom "_all" fields 以下是我们的代码 用
我在 elasticsearch 中有一个过滤别名,我使用“_all”作为绑定(bind)的索引创建了该别名。像这样: curl -XPOST "localhost:9200/_aliases" -d
我有索引“index”并输入了“fulltext”,但是当我尝试通过https://www.elastic.co/guide/en/elasticsearch/reference/6.0/mappin
我有一个分割的字段,例如: //name .startObject(IndexConstants.FIRST_NAME) .f
我正在尝试在 match 中实现Elasticsearch搜索,并且我注意到行为是不同的,具体取决于我是否使用_all还是输入特定的字符串值作为查询的字段名称。 为了提供一些背景信息,我创建了具有以下
我相信这是Rails 3中的一个错误。我希望这里的人能够引导我朝正确的方向发展。下面发布的代码仅用于说明此问题。希望这不会混淆这个问题。 给定我有一个Post模型和一个Comment模型。发表has_
Elasticsearch suggested在我的例子中禁用 _source 和 _all 字段,这是我的映射 { "template": "mq-body-*", "settings":
我正在使用 tire 来实现对 Rails 应用程序的搜索。该应用程序由实现 ActiveModel 的 CouchDB 和 couchrest_model gem 提供支持。 从自述文件可以看出有一
(Elasticsearch 5.2.2) 我在突出显示以正常工作方面遇到了一些麻烦。 我的映射具有2个自定义创建的_all-fields myall1 和 myall2 ,它们是通过 copy_to
我是一名优秀的程序员,十分优秀!