ElasticSearch 常用设置

Posted Neo的技术点滴

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ElasticSearch 常用设置相关的知识,希望对你有一定的参考价值。

 

2.2.0的启动和6.几 启动路径、端口一样,但是进入Head的路径不一样

http://localhost:9200/

 

 进入Head的方式2.2 的在

http://localhost:9200/_plugin/head/

 

进入6.几的方式

先要自己下载,把Head拷贝进去目录。然后修改配置文件,

然后,在head源代码目录下启动nodejs:

grunt server

效果如图:

最后在9100端口进入Head

http://localhost:9100

 

 

 

分词查找

http://localhost:9200/_analyze?analyzer=ik_max_word&&text=中华人民共和国

 

查看Mapping的方法

http://127.0.0.1:9200/jlindex/_mapping?pretty

 

通过Head的复合查询设置Mapping(文本禁用分词)

找到Head的复合查询部分

 

在查询第一行填入地址和要创建索引的名称,例如索引的名称是jlindex

 

 

另外,查询下左边栏位置空,右边栏位因为是新增索引和设置Mapping,所以设置为POST

把要提交的Mapping粘贴进去,点击提交按钮即可完成新建索引的Mapping

 

 

{
    "mappings": {
        "saledatatype": {
            "properties": {
                "FYear": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "FQuarter": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "FMonth": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "FDate": {
                    "type": "date",
                    "format": "strict_date_optional_time||epoch_millis"
                },
                "City": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "CustomerName": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "FAmount": {
                    "type": "double"
                },
                "FItemClassID": {
                    "type": "long"
                },
                "FItemID": {
                    "type": "long"
                },
                "FItemID1": {
                    "type": "long"
                },
                "FItemID2": {
                    "type": "long"
                },
                "FItemID3": {
                    "type": "long"
                },
                "FItemID4": {
                    "type": "long"
                },
                "FItemID5": {
                    "type": "long"
                },
                "FItemID6": {
                    "type": "long"
                },
                "FName": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "FName1": {
                    "type": "string",
                    "index": "not_analyzed"

                },
                "FName2": {
                    "type": "string",
                    "index": "not_analyzed"

                },
                "FName3": {
                    "type": "string",
                    "index": "not_analyzed"

                },
                "FName4": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "FName5": {
                    "type": "string",
                    "index": "not_analyzed"

                },
                "FName6": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "FNumber": {
                    "type": "string",
                    "index": "not_analyzed"

                },
                "FNumber1": {
                    "type": "string",
                    "index": "not_analyzed"

                },
                "FNumber2": {
                    "type": "string",
                    "index": "not_analyzed"

                },
                "FNumber3": {
                    "type": "string",
                    "index": "not_analyzed"

                },
                "FNumber4": {
                    "type": "string",
                    "index": "not_analyzed"

                },
                "FNumber5": {
                    "type": "string",
                    "index": "not_analyzed"

                },
                "FNumber6": {
                    "type": "string",
                    "index": "not_analyzed"

                },
                "FQTy": {
                    "type": "double"
                },
                "ItemName": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "ItemNumber": {
                    "type": "string",
                    "index": "not_analyzed"

                },
                "Province": {
                    "type": "string",
                    "index": "not_analyzed"

                }
            }
        }
    }
}

 

 

 设置IK分词

{
    "mappings": {
        "saledatatype": {
            "properties": {
                "City": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"
                },
                "CustomerName": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"
                },
                "FAmount": {
                    "type": "double"
                },
                "FDate": {
                    "type": "date",
                    "format": "strict_date_optional_time||epoch_millis"
                },
                "FItemClassID": {
                    "type": "long"
                },
                "FItemID": {
                    "type": "long"
                },
                "FItemID1": {
                    "type": "long"
                },
                "FItemID2": {
                    "type": "long"
                },
                "FItemID3": {
                    "type": "long"
                },
                "FItemID4": {
                    "type": "long"
                },
                "FItemID5": {
                    "type": "long"
                },
                "FItemID6": {
                    "type": "long"
                },
                "FName": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                },
                "FName1": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                },
                "FName2": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                },
                "FName3": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                },
                "FName4": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                },
                "FName5": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                },
                "FName6": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                },
                "FNumber": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                },
                "FNumber1": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                },
                "FNumber2": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                },
                "FNumber3": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                },
                "FNumber4": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                },
                "FNumber5": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                },
                "FNumber6": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                },
                "FQTy": {
                    "type": "double"
                },
                "ItemName": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                },
                "ItemNumber": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                },
                "Province": {
                    "type": "string",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"

                }
            }
        }
    }
}

 

以上是关于ElasticSearch 常用设置的主要内容,如果未能解决你的问题,请参考以下文章

常用的几个JQuery代码片段

ElasticSearch学习问题记录——Invalid shift value in prefixCoded bytes (is encoded value really an INT?)(代码片段

ElasticSearch 常用设置

配置 VScode 编辑器 (前端篇)

Elasticsearch--搜索

C#常用代码片段备忘