Skip to content

ElasticSearch

July 1, 2016

ES problem was handling of relationships:

1. handle it at app level – hit two different indices. with ID’s
2. Nested children – problem is re-indexing of parent every time children are updated, mapping has to be of nested type. costly if too many children
3. Parent Child – can do : parent indexed separately and children indexed separately. link is mantained between them.
children can be queried separately. need not tranverse thru parent

Char Filter-> Tokenizer -> Token Filter

term/ term(s) : not analyzed

wildcards
filters
missing
must_not
query_string
range
field{ gte, lte }

The term query does not analyze the search term, the match query uses the same analyzer for search as was used to index the field

query: filtered : [query, filter ]
query : match_phrase or query :match : field { query: value, type:match_phrase}
query: must : match : field
query : bool or query->filtered->filter:bool
query:fitleredXXXbool does not work
query_string

query
filtered filter OR / AND / EXISTS/

filtered
query
match, latest

must is keep score count, should does not add to score count
term does not use analyzer, must uses the default analyzer,

match_phrase query is the one you should reach for when you want to find words that are near each other:

{
    "query_string" : {
        "fields" : ["city.*","name","age"],
        "query" : "this AND that OR thus",
        "use_dis_max" : true
    }
}

query -> match_phrase

 

multi field mapping with two mappings – one is for existing token other is not analyzed

"title": {
    "type": "multi_field",
    "fields": {
        "title": { "type": "string" },
        "raw":   { "type": "string", "index": "not_analyzed" }
    }
}

or

"title": {
    "type": "string",
    "fields": {
        "raw":   { "type": "string", "index": "not_analyzed" }
    }
}
Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: