Skip to content

Instantly share code, notes, and snippets.

@johtani
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johtani/9184287 to your computer and use it in GitHub Desktop.
Save johtani/9184287 to your computer and use it in GitHub Desktop.
nestedなデータのハイライトの奇妙な動作と、再現データ(ES1.0、0.90.11で確認)
DELETE /bookstore
PUT /bookstore
POST /bookstore/books/_mapping
{
"books" : {
"properties": {
"book" : {
"type": "nested",
"properties": {
"title" : { "type": "string", "analyzer": "kuromoji", "store": "no"},
"contents" : {"type": "string", "analyzer": "kuromoji", "store": "yes"}
}
}
}
}
}
PUT /bookstore/books/1
{
"book" : {
"title" : "Apache Solr入門",
"contents" : "Apache Solrについて日本語で書かれた唯一の書籍です。SolrはLuceneをコアにした検索サーバです。"
}
}
PUT /bookstore/books/2
{
"book" : {
"title" : "ElasticSearch Server",
"contents" : "ElasticSearch Serverの日本語版の書籍です。PacktPublishingから出版されている書籍を0.90対応して日本語にしました。Luceneをコアにした全文検索サーバです。"
}
}
## ハイライトが帰ってこない
GET /bookstore/books/_search
{
"query": {
"nested": {
"path": "book",
"query": {
"query_string" : {
"query" : "Solr",
"fields" : ["book.title", "book.contents"]
}
}
}
},
"highlight": {
"pre_tags": ["<b>"],
"post_tags": ["</b>"],
"fields": {
"*": {}
}
}
}
## ハイライトが帰ってくる(ただし、titleのみ)
GET /bookstore/books/_search
{
"query": {
"query_string" : {
"query" : "Solr"
}
},
"highlight": {
"pre_tags": ["<b>"],
"post_tags": ["</b>"],
"fields": {
"book.title" : {},
"book.contents": {}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment