gpt4 book ai didi

elasticsearch - Elasticsearch更改相似性不起作用

转载 作者:行者123 更新时间:2023-12-02 23:25:33 24 4
gpt4 key购买 nike

更改索引的相似性算法无效。我不想比较BM25与TF-IDF,但是我总是得到相同的结果。我正在使用Elasticsearch5.x。

我已经尝试了一切。将属性的相似性设置为classicBM25或不进行任何设置

"properties": {
"content": {
"type": "text",
"similarity": "classic"
},

我还尝试在 settings中设置索引的默认相似度,并在 properties中使用它
"settings": {
"index": {
"number_of_shards": "5",
"provided_name": "test",
"similarity": {
"default": {
"type": "classic"
}
},
"creation_date": "1493748517301",
"number_of_replicas": "1",
"uuid": "sNuWcT4AT82MKsfAB9JcXQ",
"version": {
"created": "5020299"
}
}

我正在测试的查询看起来像这样:
{
"query": {
"match": {
"content": "some search query"
}
}
}

最佳答案

我在下面创建了一个示例:

DELETE test
PUT test
{
"mappings": {
"book": {
"properties": {
"content": {
"type": "text",
"similarity": "BM25"
},
"subject": {
"type": "text",
"similarity": "classic"
}
}
}
}
}

POST test/book/1
{
"subject": "A neutron star is the collapsed core of a large (10–29 solar masses) star. Neutron stars are the smallest and densest stars known to exist.[1] Though neutron stars typically have a radius on the order of 10 km, they can have masses of about twice that of the Sun.",
"content": "A neutron star is the collapsed core of a large (10–29 solar masses) star. Neutron stars are the smallest and densest stars known to exist.[1] Though neutron stars typically have a radius on the order of 10 km, they can have masses of about twice that of the Sun."
}
POST test/book/2
{
"subject": "A quark star is a hypothetical type of compact exotic star composed of quark matter, where extremely high temperature and pressure forces nuclear particles to dissolve into a continuous phase consisting of free quarks. These are ultra-dense phases of degenerate matter theorized to form inside neutron stars exceeding a predicted internal pressure needed for quark degeneracy.",
"content": "A quark star is a hypothetical type of compact exotic star composed of quark matter, where extremely high temperature and pressure forces nuclear particles to dissolve into a continuous phase consisting of free quarks. These are ultra-dense phases of degenerate matter theorized to form inside neutron stars exceeding a predicted internal pressure needed for quark degeneracy."
}

GET test/_search?explain
{
"query": {
"match": {
"subject": "neutron"
}
}
}
GET test/_search?explain
{
"query": {
"match": {
"content": "neutron"
}
}
}
subjectcontent字段的相似性定义不同,但是在我提供的两个文档(来自Wikipedia)中,它们具有相同的文本。运行两个查询,您将在解释中看到类似以下内容,并且在结果中得到不同的分数:

第一个查询的
  • :"description": "idf, computed as log((docCount+1)/(docFreq+1)) + 1 from:"
  • 从第二个开始的
  • :"description": "idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:",
  • 关于elasticsearch - Elasticsearch更改相似性不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43745572/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com