【问题标题】:Why does elastic search returns response <Response [400]> when trying to index?为什么弹性搜索在尝试索引时返回响应 <Response [400]>?
【发布时间】:2021-03-06 09:41:49
【问题描述】:

我正在尝试按照教程进行操作 - 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 排名功能检索它们。

【问题讨论】:

    标签: python elasticsearch search full-text-search search-engine


    【解决方案1】:

    调用 response.json() 或 response.text 会给您响应正文,这可能会告诉您请求的确切问题

    【讨论】:

    • 知道了。使用响应主体,我能够解决错误。谢谢:)
    猜你喜欢
    • 2021-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-24
    相关资源
    最近更新 更多