Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# elasticsearch中的子字符串搜索_C#_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch - Fatal编程技术网 elasticsearch,C#,elasticsearch" /> elasticsearch,C#,elasticsearch" />

C# elasticsearch中的子字符串搜索

C# elasticsearch中的子字符串搜索,c#,elasticsearch,C#,elasticsearch,我有一个存储在弹性搜索中的文档(搜索URI为:)和数据 { "id": "11111", "name": "PROMO GORE-TEX GLOVE", "parent": "ST26923", "price": "20" } 现在,如果我提供搜索字符串作为“PROMO”或“GORE-TEX”或“GLOVE”,我需要从文档中获取数据,就像子字符串搜索一样。我在谷歌上搜索过,但没有得到明确的答案。 如何执行子字符串搜索要搜索子字符串,最好将此字段定义为未分析,然

我有一个存储在弹性搜索中的文档(搜索URI为:)和数据

{

    "id": "11111",
    "name": "PROMO GORE-TEX GLOVE",
    "parent": "ST26923",
    "price": "20"
}
现在,如果我提供搜索字符串作为“PROMO”或“GORE-TEX”或“GLOVE”,我需要从文档中获取数据,就像子字符串搜索一样。我在谷歌上搜索过,但没有得到明确的答案。
如何执行子字符串搜索要搜索子字符串,最好将此字段定义为未分析,然后使用通配符

"query": {
    "wildcard": {
       "name": {
          "value": "PROMO GORE*"
       }
    }
}
要指定未分析的字符串,必须在将数据放入elasticsearch之前指定映射

{
"infypos": {
      "mappings": {
         "product": {
            "properties": {
               "name": {
                  "type": "string",
                  "index":    "not_analyzed"
               },
               "parent": {
                  "type": "string"
               },
               "price": {
                  "type": "long"
               }
            }
         }
      }
  }
}

我通过运行C#代码并将JSON数据作为HTTPWebRequest传递来创建索引。如果我要创建一个映射或将该字段定义为未分析字段,我该怎么做?您可能应该使用NEST。(官方Elasticsearch.NET客户端)。您可以很容易地从嵌套定义映射。如果您对它感到满意,它还使用fluentapi。请看这里:如果您没有定义任何显式映射,那么子字符串匹配将起作用,您能用
curl-s-XGET'的输出编辑您的问题吗http://localhost:9200/enerknol/policy_data/_mapping“
还有您的查询?