# ES

## 索引结构设计

```javascript
{
    "mapping":{
        "house":{
            "dynamic":false,
            "properties":{
                "title":{
                    "type":"text",
                    "index":"analyzed"
                }
                ...
            }
        }
    }
}
```

中文分词 index：analyzed

type:keyword,text,integer,data,long

## 索引结构模板

```java
public class HouseIndexTemplate{
    private String title;
    ...
}
```

索引关键字统一定义

```java
public class HouseIndexKey{
    public static final String TITLE="title"
}
```

## 索引构建

## 搜索引擎

```java
public void query(){
    BoolQueryBuilder boolQuery=QueryBuilders,boolQuery();
    boolQuery.filter(QueryBuilders.termQuery(CITY_EN_NAME,rentSearch.getCityEnName()));
    SearchRequestBuilder requestBuilder=this.esClient.prepareSearch(INDEX_NAME)
        .serType(INDEX_TYPE)
        .setQuery(boolQuery)
        .addSort()
        .setFrom()
        .setSize()
}
```

## 中文分词

/\_analyze?analyzer=stadard\&pretty=true\&text=Well,Wall is a handsome teacher

/\_analyze?analyzer=stadard\&pretty=true\&text=瓦力是一个英俊的老师

elasticSearch默认分词是以每个“字”为单位的

elasticsearch-analysis-ik-5.6.1.zip

```javascript
{
    "title":{
        "type":"text",
        "index":"analyzed",
        "analyzer":"ik_smart",
        "search_analyzer":"ik_smart"
    }
}
```

## Search-as-your-type


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://moluo.gitbook.io/notes/bian-cheng-xue-xi/shu-ju-ku/elasticsearch/es.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
