【问题标题】:Elastic search " settings " add in Python module在 Python 模块中添加弹性搜索“设置”
【发布时间】:2015-01-30 07:14:31
【问题描述】:

如何将以下设置添加到 python 弹性搜索模块。请举个例子。我已经创建了索引和映射。但我被设置困住了。

curl -XPUT "http://localhost:9200/blurays " -d'
{
   "settings": {
     "analysis": {
     "filter": {
        "nGram_filter": {
           "type": "nGram",
           "min_gram": 2,
           "max_gram": 20,
           "token_chars": [
              "letter",
              "digit",
              "punctuation",
              "symbol"
           ]
        }
     },
     "analyzer": {
        "nGram_analyzer": {
           "type": "custom",
           "tokenizer": "whitespace",
           "filter": [
              "lowercase",
              "asciifolding",
              "nGram_filter"
           ]
        },
        "whitespace_analyzer": {
           "type": "custom",
           "tokenizer": "whitespace",
           "filter": [
              "lowercase",
              "asciifolding"
           ]
        }
     }
  }
 },

【问题讨论】:

  • 你想用这个设置做什么?您想将此设置推送到索引吗?
  • @Lafada 是的,伙计。我希望在我的索引中使用这些设置。我必须使用这些设置上传一些文档,最后我想实现一个自动完成建议。
  • 你想用 py-elasticsearch 模块来做这个吗?
  • @Lafada - 没错。使用 py-elasticsearch 模块。请帮忙。

标签: python search elasticsearch


【解决方案1】:

如果您的索引已经存在,您可以使用elasticsearch.indices.put_settings 更新其设置。

【讨论】:

    【解决方案2】:

    您可以使用elasticsearch.indices.create 并将设置作为正文传递。

    文档说:

    创建(*args, **kwargs)

    在 Elasticsearch 中创建索引。 http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-create-index.html

    参数:

    • index – 索引的名称
    • body – 索引的配置(设置和映射)
    • master_timeout – 指定连接到 master 的超时时间
    • timeout – 显式操作超时

    所以你可以通过设置参数传递body

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-05
      • 1970-01-01
      相关资源
      最近更新 更多