lucene - How to query a phrase with stopwords in ElasticSearch -


i indexing text stopwords enabled , search against these using "match phrase" query without slop, looks stopwords still taking in account terms positions.

building index:

put /fr_articles {    "settings": {       "analysis": {          "analyzer": {             "stop": {                "type": "standard",                "stopwords" : ["the"]             }          }       }    },    "mappings": {       "test": {          "properties": {             "title": {                "type": "string",                "analyzer": "stop"             }          }       }    } } 

add document:

post /fr_articles/test/1 {     "title" : "tom king of toulon!" } 

search:

post /fr_articles/_search {    "fields": [       "title"    ],    "explain": true,    "query": {       "match": {          "title": {             "query": "tom king",             "type" : "phrase"          }       }    } } 

nothing found ;-(

is there way fix it? or maybe multiple span queries, want term near each other.

thanks you,

the position increments cause issue, yes. while stop word may gone , not searchable, still doesn't shove 2 words next each other, query "tom king" finds neither "tom king" nor "such tom not king".

often, when remove in analysis filter, it's not quite if never there. intent of stopfilter, in particular, remove search hits resulting uninteresting terms. not change structure of document or sentence.

you used able disable position increments, on stopfilter, option has been removed, of lucene 4.4.


okay, forget charfilter tomfoolery. ugly hack, don't that.

to query without using position increments, need configure in query parser, not in analysis. can done in elasticsearch, query string query, enable_position_increments set false.

something like:

{     "query_string" : {         "default_field" : "title",         "query" : "\"tom king\""         "enable_position_increments" : false     } } 

as point of interest, similar solution in raw lucene, setting queryparser.setenablepositionincrements.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -