为什么弹性搜索在尝试索引时返回response<response[400]>?

2024-05-16 02:41:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着跟着教程走-http://ethen8181.github.io/machine-learning/search/bm25_intro.html#ElasticSearch-BM25

我通过作为守护进程运行成功地启动了弹性节点,它在发出查询-curl -X GET "localhost:9200/时做出了响应

当我尝试在这里运行以下代码时,它返回400


settings = {
    'settings': {
        'index': {
            'number_of_shards': 1,
            'number_of_replicas': 1,

            'similarity': {
                'default': {
                    'type': 'BM25'
                }
            }
        }
    },
   
    'mappings': {
        '_doc': {
            'properties': {
                'title': {
                    'type': 'text',
                    'analyzer': 'english'
                }
            }
        }
    }
}
headers = {'Content-Type': 'application/json'}
response = requests.put('http://localhost:9200/experiment', data=json.dumps(settings), headers=headers)
response

我在这里做错了什么?我该如何解决这个问题

我基本上是试图索引一组文档,并使用BM25排名函数检索它们


Tags: ofiogithubjsonlocalhosthttpnumbersettings