Skip to content

Instantly share code, notes, and snippets.

@kundo
Created July 12, 2012 12:16
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 kundo/3097781 to your computer and use it in GitHub Desktop.
Save kundo/3097781 to your computer and use it in GitHub Desktop.
No highlight in elasticsearch with Fuzzy Like This Query
QUERY:
curl -XGET 'http://localhost:9200/forum_4/dialog/_search?pretty=true' -d '{"highlight": {"pre_tags": ["<span class=highlighted>"], "fields": {"title": {"fragment_size": 150, "number_of_fragments": 1}}, "post_tags": ["</span>"]}, "query": {"fuzzy_like_this": {"like_text": "i18n", "fields": ["title"]}}}}'
RESPONSE:
{
"took" : 5,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.75,
"hits" : [ {
"_index" : "forum_4",
"_type" : "dialog",
"_id" : "1245",
"_score" : 1.75, "_source" : {"other_comments_text": "", "tags": "", "text": "\t Hi I\u00b4ve seen your version og getsatisfaction and I\u00b4m wondering how could I translate into Spanish and German\u00bf Can you advice\u00bf \n\n\t my email: natalia.mindykowska@ibotanika.com ", "num_votes": 1, "topic": "Q", "last_activity": "2009-07-20T12:24:25", "user": {"first_name": "Natalia", "id": 488}, "pub_date": "2009-07-20T10:22:26", "id": 1245, "org_comments_text": "Some reply", "archived": false, "title": "i18n of feedback ", "num_comments": 1, "absolute_url": "/org/kundo/d/i18n-of-feedback/"}
} ]
}
}
MAPPING:
{
'title': {
'boost': 2.5,
'type': 'string',
'term_vector': 'with_positions_offsets'
},
'text': {
'boost': 1.0,
'type': 'string'
},
'org_comments_text': {
'boost': 0.5,
'type': 'string'
},
'other_comments_text': {
'boost': 0.2,
'type': 'string'
},
'tags': {
'boost': 0.2,
'type': 'string'
},
'absolute_url': {
'type': 'string',
'index': u'not_analyzed',
},
'topic': {
'type': 'string',
'index': u'not_analyzed',
},
'pub_date': {
'type': 'date',
'index': u'not_analyzed',
},
'last_activity': {
'type': 'date',
'index': u'not_analyzed',
},
'num_comments': {
'type': 'integer',
'index': u'not_analyzed',
},
'num_votes': {
'type': 'integer',
'index': u'not_analyzed',
},
'archived': {
'type': 'boolean',
'index': u'not_analyzed',
},
'id': {
'type': 'integer',
'index': u'not_analyzed',
},
'user': {
'type': 'multi_field',
'index': u'not_analyzed',
'fields': {
'id': {
'type': 'integer',
'index': u'not_analyzed',
},
'first_name': {
'type': 'string',
'index': u'not_analyzed',
},
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment