Giter Club home page Giter Club logo

docker-elasticsearch-ik-traditional-chinese's Introduction

Docker for Elasticsearch with IK Analyzer and Traditional Chinese

It is such a pain to configure IK Analyzer for Traditional Chinese. Thus, this repository provides a properly configured Docker image for Elasticsearch with IK Analysis plugin and Traditional Chinese dictionaries.

The image uses Elasticsearch version 7.16.2.

Usage

docker run --rm -p 9200:9200 -e "discovery.type=single-node" --memory 5G minghsu0107/elasticsearch-chinese:7.16.2

Test Simplified Chinese

create an index:

curl -XPUT http://localhost:9200/index0

Create a mapping:

curl -XPOST http://localhost:9200/index0/_mapping -H 'Content-Type:application/json' -d'
{
        "properties": {
            "content": {
                "type": "text",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_smart"
            }
        }

}'

Index some docs:

curl -XPOST http://localhost:9200/index0/_create/1 -H 'Content-Type:application/json' -d'
{"content":"美国留给伊拉克的是个烂摊子吗"}
'
curl -XPOST http://localhost:9200/index0/_create/2 -H 'Content-Type:application/json' -d'
{"content":"公安部:各地校车将享最高路权"}
'
curl -XPOST http://localhost:9200/index0/_create/3 -H 'Content-Type:application/json' -d'
{"content":"中韩渔警冲突调查:韩警平均每天扣1艘**渔船"}
'
curl -XPOST http://localhost:9200/index0/_create/4 -H 'Content-Type:application/json' -d'
{"content":"**驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}
'

Query with highlighting:

curl -XPOST http://localhost:9200/index0/_search  -H 'Content-Type:application/json' -d'
{
    "query" : { "match" : { "content" : "**" }},
    "highlight" : {
        "pre_tags" : ["<tag1>", "<tag2>"],
        "post_tags" : ["</tag1>", "</tag2>"],
        "fields" : {
            "content" : {}
        }
    }
}
'

Test Traditional Chinese

Create an index:

curl -XPUT http://localhost:9200/index1

Create a mapping:

curl -XPOST http://localhost:9200/index1/_mapping -H 'Content-Type:application/json' -d'
{
        "properties": {
            "content": {
                "type": "text",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_smart"
            }
        }

}'

Index some docs:

curl -XPOST http://localhost:9200/index1/_create/1 -H 'Content-Type:application/json' -d'
{"content":"陸美貿易戰已變成科技戰甚至正開打貨幣戰"}
'
curl -XPOST http://localhost:9200/index1/_create/2 -H 'Content-Type:application/json' -d'
{"content":"美國2年期公債殖利率與10年期殖利率利差上周出現倒掛"}
'
curl -XPOST http://localhost:9200/index1/_create/3 -H 'Content-Type:application/json' -d'
{"content":"用露營車產業來判斷美國經濟是否出現衰退,比經濟學家的預測更精準。"}
'
curl -XPOST http://localhost:9200/index1/_create/4 -H 'Content-Type:application/json' -d'
{"content":"被視為判斷美國經濟是否走向衰退的另一指標「露營車」出貨量也明顯下滑"}
'

Query with highlighting:

curl -XPOST http://localhost:9200/index1/_search  -H 'Content-Type:application/json' -d'
{
    "query" : { "match" : { "content" : "美國" }},
    "highlight" : {
        "pre_tags" : ["<tag1>", "<tag2>"],
        "post_tags" : ["</tag1>", "</tag2>"],
        "fields" : {
            "content" : {}
        }
    }
}
'

Reference

docker-elasticsearch-ik-traditional-chinese's People

Contributors

minghsu0107 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.