私信  •  关注

Pierre Mallet

Pierre Mallet 最近创建的主题
Pierre Mallet 最近回复了
7 年前
回复了 Pierre Mallet 创建的主题 » Elasticsearch-如果匹配的单词越多,文档得分越高

您应该在查询中添加短语匹配的增强。因此,在多个filterValues中找到所有查询项的文档自然会得到增强。

但你得小心这个怪癖( see here, official doc )

我不知道是怎么回事(也许你身上有原力),但你的地图已经对了 position_increment_gap 但是你应该删除设置

search_analyzer:“小写_shingle”

因为在你的背景下似乎有点奇怪。

然后我们在匹配短语上加上boost

{
    "query": {
        "bool": {
            "must": [
                {
                    "match": {
                        "filterValues": "ordner ohne griffloch"
                    }
                }
            ],
            should: [
              {
                "match_phrase": {
                        "filterValues": {
                          "query": "ordner ohne griffloch",
                          "slop": 10 
                        }

                    }
                }
            ]
        }
    }
}

希望能成功!

评论后编辑:

如果更改映射,以便在索引时使用shingle_分析器添加子字段

"mappings": {
    "filter": {
      "properties": {
        "filterValueId": {
          "type": "long"
        },
        "filterValues": {
          "type": "text",
          "position_increment_gap": 100,
          "analyzer": "default",
          "search_analyzer": "lowercase_shingle",
          "fields": {
              "shingled": {
                   "type": "text",
                   "analyzer": "lowercase_shingle",
              }
          }
        },
        "categoryId": {
          "type": "long"
        }
      }
    }
  }

然后,您可以使用此查询在shingled子字段上添加一个boost

{
        "query": {
            "bool": {
                "must": [
                    {
                        "match": {
                            "filterValues": "ordner ohne griffloch"
                        }
                    }
                ],
                should: [
                  {
                    "match": {
                            "filterValues.shingled": "ordner ohne griffloch" 
                        }
                    }
                ]
            }
        }
    }

在你的例子中,第二个博士而不是第一个博士

7 年前
回复了 Pierre Mallet 创建的主题 » 在ElasticSearch中存储数据的正确方法是什么?

这取决于每天的警报数量,但我认为最好的选择是3:D。

选项3:将所有警报保持在一个 Index 同一类型。并在查询时使用过滤器。

不赞成在一个索引下使用不同的类型,因为版本5在版本6中无法完成,并且将在版本7中最终删除。

在ElasticSearch 6.0.0或更高版本中创建的索引只能包含单个映射类型。在5.x中创建的具有多个映射类型的索引将继续像在ElasticSearch 6.x中那样工作。将在ElasticSearch 7.0.0中完全删除映射类型。

here 更多信息

不要使用多类型索引,除非您希望在升级到较新版本的ElasticSearch时进行主要重构。