Elasticsearch 5.0.2无法搜索关键字

时间:2016-12-13 02:33:27

标签: elasticsearch

我正在使用字段定义索引一个非常简单的项目:

// res/values/styles.xml 
<style name="SomeStyle" parent="MyAppTheme">
    <item name="android:background">@drawable/selector_background</item>
</style>

<style name="SomeTextView" parent="@android:style/TextAppearance">
    <item name="android:textColor">@drawable/selector_text</item>
</style>

// Styling the text color selector  
// res/drawable/selector_text.xml  
<?xml version="1.0" encoding="utf-8"?>
<selector
    xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:color="@color/inactive_color" android:state_focused="true" android:state_pressed="false"/>
    <item android:color="@color/active_color" android:state_pressed="true"/>
    <item android:color="@color/active_color" android:state_drag_hovered="true" android:state_pressed="true"/>
    <item android:color="@color/active_color" android:state_selected="true" android:state_pressed="true"/>
    <item android:color="@color/inactive_color"/>

</selector>

// The background selector
// res/drawable/selector_background.xml  
<?xml version="1.0" encoding="utf-8"?>
<selector
    xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/background_selector_unselected" android:state_focused="true" android:state_pressed="false"/>
    <item android:drawable="@drawable/background_selector_selected" android:state_pressed="true"/>
    <item android:drawable="@drawable/background_selector_unselected"/>

</selector>

// Styling the selected background state
// res/drawable/selector_background_state_active.xml  
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/shadow_color_1" />
        </shape>
    </item>
    <item android:bottom="1dp">
        <shape android:shape="rectangle">
            <solid android:color="@color/shadow_color_2" />
        </shape>
    </item>
    <item android:bottom="1.5dp">
        <shape android:shape="rectangle">
            <solid android:color="@color/active_background_color" />
        </shape>
    </item>
</layer-list>

然后我摄取了一个项目,其中comid =“这是一个id” 当我查询具有完全匹配的项目时“这是一个id”

我收到了这个错误:

"comid": {
  "type": "keyword",
  "store": "false",
  "index": "no",
  "include_in_all": false, 
  "doc_values": false
}

也许我误解了文档,但我认为我们可以搜索关键字(使用完全匹配)?

我想我可以通过将类型从关键字更改为文本然后使用关键字分析器(如果我正确理解它是noop)来解决这个问题,但对每个关键字类型字段执行此操作似乎很奇怪。

我一定错过了一些明显的东西吗?

1 个答案:

答案 0 :(得分:0)

如果没有编入索引,则字段数据仅存储在文档中,而不是索引中,因此您无法使用该字段进行搜索。

请参阅:https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-index.html