# How get more accuracy search result when inputing chinese text directly?

**URL:** <https://discuss.elastic.co/t/how-get-more-accuracy-search-result-when-inputing-chinese-text-directly/82395>\
**Category:** Elasticsearch\
**Created:** [April 14, 2017, 9:57am UTC](https://discuss.elastic.co/t/how-get-more-accuracy-search-result-when-inputing-chinese-text-directly/82395 "2017-04-14T09:57:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hellosearch](https://avatars.discourse-cdn.com/v4/letter/h/ecb155/32.png) [@hellosearch](https://discuss.elastic.co/u/hellosearch)\
**Post date:** [April 14, 2017, 9:57am UTC](https://discuss.elastic.co/t/how-get-more-accuracy-search-result-when-inputing-chinese-text-directly/82395/1 "2017-04-14T09:57:09Z")

</div>

Hi  
Let me explain my question:  
There is a document that include movie starring. for example:  
{"index": {"\_id": "2"}}  
{ "starring": "邓光荣##区瑞强", "workName": "怒拔太阳旗", "length": "85:17"}

i set below mapping for starring filed:  
curl -XPUT "[http://localhost:9200/metadata/](http://localhost:9200/metadata/)" -d'  
{  
"index" : {  
"analysis" : {  
"analyzer" : {  
"name\_analyzer" : {  
"tokenizer" : "name\_tokenizer",  
"filter" : ["full\_pinyin\_no\_space","my\_edge\_ngram\_tokenizer"]  
}  
},"tokenizer": {  
"name\_tokenizer": {  
"type": "pattern",  
"pattern": "##"  
}  
},  
"filter" :{  
"full\_pinyin\_no\_space" : {  
"type" : "pinyin",  
"first\_letter" : "none",  
"keep\_separate\_first\_letter": true,  
"padding\_char" : ""  
},"my\_edge\_ngram\_tokenizer" : {  
"type" : "edge\_ngram",  
"min\_gram" : "1",  
"max\_gram" : "6",  
"token\_chars": ["letter", "digit"]  
}  
}  
}  
}  
}'

curl -XPOST [http://localhost:9200/metadata/movies/\_mapping](http://localhost:9200/metadata/movies/_mapping) -d '  
{  
"properties": {  
"starring":{  
"type": "string",  
"analyzer": "ik\_max\_word",  
"fields": {  
"pinyin":{  
"type": "string",  
"analyzer": "name\_analyzer"  
}  
}  
}  
}  
}'

so this process will return result when inputing "邓光荣" or "dgr" of first letter of "邓光荣" as search keywords.

my question is how to get more accuracy result that only include "邓光荣" if inputing chinese text "邓光荣" ?

when searching starring filed, whether i may set different analyzer dynamicly for every search ?

thanks very much~~

---

<div class="post-metadata">

**Author:** ![s1monw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/s1monw/32/3637_2.png) [@s1monw](https://discuss.elastic.co/u/s1monw)\
**Post date:** [April 21, 2017, 7:40am UTC](https://discuss.elastic.co/t/how-get-more-accuracy-search-result-when-inputing-chinese-text-directly/82395/2 "2017-04-21T07:40:53Z")

</div>

one way to do this given I understand your question correctly is to use an additional query clause to boost hits that fully match the query term. Your analyzer produces edge\_ngram ie. `邓光荣 -> [邓, 邓光, 邓光荣]` such that docs that have `邓光` will still match and might be scored better. One option would be to add a `should` clause to your query with a term query on that field that will not be analyzed at all like this:

```auto
"term" : { "starring" : "邓光荣" } 

```

that will give docs matching this name a boost compared to other hits on partial ngrams

hope that helps

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 19, 2017, 7:50am UTC](https://discuss.elastic.co/t/how-get-more-accuracy-search-result-when-inputing-chinese-text-directly/82395/3 "2017-05-19T07:50:59Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
