ElasticSearch术语搜索在数组字段中失败,带有中文单词

时间:2016-09-13 13:52:31

标签: elasticsearch cjk term

package mypackage;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.AdapterView;

public class MainActivity extends Activity {

    ListView lv;

    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    listView.setOnItemClickListener(new     AdapterView.OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view, int     position, long id) {   
    Intent myIntent = new Intent(MainActivity.this,     SecondActivity.class);
    startActivity(myIntent);
    }
    });

使用{ "name": "张三", "uuid": "U1", "desc": "张三是百度的技术总监", "status": "1000", "tags": [ "tech", "百度", "技术" ] }, { "name": "李四", "uuid": "U2", "desc": "李四也是百度的,是设计总监", "status": "1000", "tags": [ "百度", "设计", "design" ] }, { "name": "王五", "uuid": "U3", "desc": "王五也是百度的,不过离职了", "status": "2000", "tags": [ "百度", "技术", "离职", "tech", "design" ] } 方法搜索数组字段_search

使用英语单词作为术语来搜索tags,一切顺利。

查询:

tags

搜索结果:

{
    "query": {
        "bool": {
            "must": [
                {
                    "term": {
                        "tags": "tech"
                    }
                }
            ],
        }
    }
}

使用中文单词作为搜索{ { "took": 1, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 2, "max_score": 0.4375, "hits": [ { "_index": "test", "_type": "data", "_id": "U1", "_score": 0.4375, "_source": { "name": "张三", "uuid": "U1", "desc": "张三是百度的技术总监", "status": "1000", "tags": [ "tech", "百度", "技术" ] } }, { "_index": "test", "_type": "data", "_id": "U3", "_score": 0.3125, "_source": { "name": "王五", "uuid": "U3", "desc": "王五也是百度的,不过离职了", "status": "2000", "tags": [ "百度", "技术", "离职", "tech", "design" ] } } ] } } 的术语时,不返回任何内容。

查询:

tags

结果:

{
    "query": {
        "bool": {
            "must": [
                {
                    "term": {
                        "tags": "tech"
                    }
                }
            ],
        }
    }
}

我更改了其他分析工具,例如IK,没有任何帮助。对于{ "took": 1, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 0, "max_score": null, "hits": [ ] } } desc字段,中文字词效果很好。

我该如何处理?感谢。

0 个答案:

没有答案