2017-01-02 44 views
1

首先,我創建一個索引:如何Elasticsearch設置IK分析所有指標的默認分析5.1.1

PUT blog 

然後,設置映射:

POST blog/article/_mapping 
{ 
    "article": { 
    "_all": { 
     "analyzer": "ik_max_word", 
     "search_analyzer": "ik_max_word", 
     "term_vector": "no", 
     "store": "false" 
    } 
    } 
} 

指數的一些文檔:

POST blog/article/1 
{ 
    "title":"java編程思想", 
    "content":"《Java編程思想》這本書贏得了全球程序員的廣泛讚譽" 
} 


POST blog/article/2 
{ 
    "title":"手把手教你使用Git", 
    "content":"這是一個非常容易上手的GIt詳細教程" 
} 

POST blog/article/3 
{ 
    "title":"java從入門到精通", 
    "content":"《java從入門到精通》非常適合java初學" 
} 

搜索文檔:

POST blog/_search 
{ 
    "query": { 
    "match": { 
     "title": "編程" 
    } 
    }, 
    "highlight": { 
    "fields": { 
     "title": { 
     "pre_tags": "<strong>", 
     "post_tags": "</strong>" 
     } 
    } 
    } 
} 

響應:

{ 
    "took": 4, 
    "timed_out": false, 
    "_shards": { 
    "total": 5, 
    "successful": 5, 
    "failed": 0 
    }, 
    "hits": { 
    "total": 1, 
    "max_score": 0.5649868, 
    "hits": [ 
     { 
     "_index": "blog", 
     "_type": "article", 
     "_id": "1", 
     "_score": 0.5649868, 
     "_source": { 
      "title": "java編程思想", 
      "content": "《Java編程思想》這本書贏得了全球程序員的廣泛讚譽" 
     }, 
     "highlight": { 
      "title": [ 
      "java<strong>編</strong><strong>程</strong>思想" 
      ] 
     } 
     } 
    ] 
    } 
} 

的IK分析不幹活不知道什麼領域指數在advance.How設置IK分析儀爲所有指數在Elasticsearch 5.1.1默認的分析?

+0

你如何定義你的'ik_max_word'分析儀?它從何而來? – Val

回答

1

添加以下行/etc/elasticsearch/elasticsearch.yml結束,設置IK爲默認分析:

index.analysis.analyzer.default.type: "ik" 
index.analysis.analyzer.standard.type: "ik" 
+0

它不適用於Elasticsearch 5.X. –