当我索引这样的新文档时:
ElasticClient.Index(product, idx => idx.Index(indexName));
我尝试搜索/查询此字段(这是一个500字符文本),我没有得到任何结果。我想搜索类似的东西:" 687920/1"这是500篇文字。
答案 0 :(得分:0)
下面的Elasticsearch示例可能很有用
删除pdm索引
DELETE pdm
索引映射
PUT /pdm
{
"settings":{
"analysis":{
"analyzer":{
"keyword_lowercase_analyzer": {
"type": "custom",
"filter": ["lowercase"],
"tokenizer": "keyword"
}
}
}
},
"mappings": {
"product": {
"properties": {
"product_desc": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"analyzer": "keyword_lowercase_analyzer"
},
"english": {
"type": "text",
"analyzer": "english"
}
}
}
}
}
}
}
索引文档
POST /pdm/product/_bulk
{ "index": { "_id": "111" }}
{ "product_desc": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. 687920/1 It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."}
{ "index": { "_id": "112" }}
{ "product_desc": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. 6879210/1 It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."}
搜索查询
POST /pdm/_search
{
"query": {
"match_phrase": {
"product_desc": "687920/1"
}
}
}