Nhat Le, Senior UI Engineer at WordnikAwesome slide. I wish I had found this before I jumped into ElasticSearch. This should be included in the official documentation for ES since the current Guide/API Docs is seriously lacking these information, especially for newbies like myself.2 months ago
Are you sure you want to
brianwebsteratgmaildotcomWhen viewed on Chrome on 1/16/13, some of the slides do not display correctly. http://i.imgur.com/HXFCE.png (HXFCE.png file at imgur). However, if I download and view in Power Point, it's fine.4 months ago
database table row ⇒ many tables ⇒ many rows ⇒ one schema ⇒ many columns In MySQL
index type document ⇒ many types ⇒ many documents ⇒ one mapping ⇒ many fields In ElasticSearch
Create index with mappings $es-> create_index ( index => 'twitter', mappings => { tweet => { properties => { title => { type => 'string' }, created => { type => 'date' } } } } );
Add a mapping $es-> put_mapping ( index => 'twitter', type => ' user ', mapping => { properties => { name => { type => 'string' }, created => { type => 'date' }, } } );
Can add to existing mapping
Can add to existing mapping Cannot change mapping for field
Core field types { type => 'string', }
Core field types { type => 'string', # byte|short|integer|long|double|float # date, ip addr, geolocation # boolean # binary (as base 64) }
Core field types { type => 'string', index => ' analyzed ', # 'Foo Bar' ⇒ [ 'foo', 'bar' ] }
Core field types { type => 'string', index => ' not_analyzed ', # 'Foo Bar' ⇒ [ 'Foo Bar' ] }
Core field types { type => 'string', index => ' no ', # 'Foo Bar' ⇒ [ ] }
Core field types { type => 'string', index => 'analyzed', analyzer => 'default', }
Core field types { type => 'string', index => 'analyzed', index_ analyzer => 'default', search_ analyzer => 'default', }
Core field types { type => 'string', index => 'analyzed', analyzer => 'default', boost => 2, }
Core field types { type => 'string', index => 'analyzed', analyzer => 'default', boost => 2, include_in_all => 1 |0 }
Standard
Simple
Whitespace
Stop
Keyword
Built in analyzers
Pattern
Language
Snowball
Custom
The Brown-Cow's Part_No. #A.BC123-456 joe@bloggs.com keyword: The Brown-Cow's Part_No. #A.BC123-456 joe@bloggs.com whitespace: The, Brown-Cow's, Part_No., #A.BC123-456, joe@bloggs.com simple: the, brown, cow, s, part, no, a, bc, joe, bloggs, com standard: brown, cow's, part_no, a.bc123, 456, joe, bloggs.com snowball (English): brown, cow, part_no, a.bc123, 456, joe, bloggs.com
Filters : and | or | not Query DSL: { and => [ {term=>{X=>1}}, {term=>{Y=>2}} ]} { or => [ {term=>{X=>1}}, {term=>{Y=>2}} ]} { not => { or => [ {term=>{X=>1}}, {term=>{Y=>2}} ] }} SearchBuilder: { X => 1, Y => 2 } [ X => 1, Y => 2 ] { -not => { X => 1, Y => 2 } } # and { -not => [ X => 1, Y => 2 ] } # or
Filter example SearchBuilder: { -filter => [ featured => 1, { created_at => { gt => '2011-08-01' }, status => { '!=' => 'pending' }, }, ] }
Filter example Query DSL: { constant_score => { filter => { or => [ { term => { featured => 1 }}, { and => [ { not => { term => { status => 'pending' }}, { range => { created_at => { gt => '2011-08-01' }}}, ] } ] } } }
Filters : others
script
nested
has_child
query
match_all
prefix
limit
ids
type
geo_distance
geo_distance_range
geo_bbox
geo_polygon
Text / Analyzed:
text
query_string / field
flt / flt_field
mlt / mlt_field
Term / Not analyzed:
term / terms
range
prefix
fuzzy
wildcard
ids
span queries
Combining:
bool
dis_max
boosting
Scripting:
custom_score
custom_filters_score
Wrappers:
match_all
constant_score
filtered
“ Joins”:
nested
has_child
top_children
Queries
Text / Analyzed:
text
query_string / field
flt / flt_field
mlt / mlt_field
Term / Not analyzed:
term / terms
range
prefix
fuzzy
wildcard
ids
span queries
Combining:
bool
dis_max
boosting
Scripting:
custom_score
custom_filters_score
Wrappers:
match_all
constant_score
filtered
“ Joins”:
nested
has_child
top_children
Queries
Text/Analyzed Queries mapping aware
Text/Analyzed Queries not_analyzed ⇒ term query
Text/Analyzed Queries analyzed ⇒ text query using search_analyzer
Text-Query Family Query DSL: { text => { title => 'great perl' }} Search Builder: { title => 'great perl' }
Text-Query Family Query DSL: { text => { title => { query => 'great perl' }}} Search Builder: { title => { '=' => { query => 'great perl' }}}
Text-Query Family Query DSL: { text => { title => { query => 'great perl' , operator => 'and' }}} Search Builder: { title => { '=' => { query => 'great perl', operator => 'and' }}}
Text-Query Family Query DSL: { text => { title => { query => 'great perl' , fuzziness => 0.5 }}} Search Builder: { title => { '=' => { query => 'great perl', fuzziness => 0.5 }}}
Text-Query Family Query DSL: { text => { title => { query => 'great perl', type => 'phrase' }}} Search Builder: { title => { '==' => { query => 'great perl', }}}
Text-Query Family Query DSL: { text => { title => { query => ' great perl ', type => 'phrase' }}} Search Builder: { title => { '==' => { query => ' great perl ', }}}
Text-Query Family Query DSL: { text => { title => { query => ' perl is great ', type => 'phrase' }}} Search Builder: { title => { '==' => { query => ' perl is great ', }}}
Text-Query Family Query DSL: { text => { title => { query => ' perl great ', type => 'phrase', slop => 3 }}} Search Builder: { title => { '==' => { query => ' perl great ', slop => 3 }}}
Text-Query Family Query DSL: { text => { title => { query => ' perl is gr ', type => ' phrase_prefix ', }}} Search Builder: { title => { '^' => { query => ' perl is gr ', }}}
Query string / Field Lucene Query Syntax aware “ perl is great”~5 AND author:clint* -deleted
Query string / Field Syntax errors: AND perl is great ” author : clint* -
Query string / Field Syntax errors: AND perl is great ” author : clint* - ElasticSearch::QueryParser
Combining: Bool Query DSL: { bool => { must => [ { term => { foo => 1}}, ... ], must_not => [ { term => { bar => 1}}, ... ], should => [ { term => { X => 2}}, { term => { Y => 2}},... ], minimum_number_should_match => 1, }}
Combining: Bool SearchBuilder: { foo => 1, bar => { '!=' => 1}, -or => [ X => 2, Y => 2], } { -bool => { must => { foo => 1 }, must_not => { bar => 1 }, should => [{ X => 2}, { Y => 2 }], minimum_number_should_match => 1, }}
Combining: DisMax Query DSL: { dis_max => { queries => [ { term => { foo => 1}}, { term => { bar => 1}}, ] }} SearchBuilder: { -dis_max => [ { term => { foo => 1}}, { term => { bar => 1}}, ], }
Bool: combines scores DisMax: uses highest score from all matching clauses
Tweaking relevance:
Tweaking relevance: Boosting
Boosting: at index time { properties => { content => { type => “string” }, title => { type => “string” }, }
Boosting: at index time { properties => { content => { type => “string” }, title => { type => “string”, boost => 2, }, }, }
Boosting: at index time { properties => { content => { type => “string” }, title => { type => “string”, boost => 2, }, rank => { type => “integer” }, }, _boost => { name => 'rank', null_value => 1.0 }, }
Boosting: at search time Query DSL: { bool => { should => [ { text => { content => 'perl' }}, { text => { title => 'perl' }}, ] }} SearchBuilder: { content => 'perl', title => 'perl' }
Boosting: at search time Query DSL: { bool => { should => [ { text => { content => 'perl' }}, { text => { title => { query => 'perl', }}, ] }} SearchBuilder: { content => 'perl', title => { '=' => { query => 'perl' }} }
Boosting: at search time Query DSL: { bool => { should => [ { text => { content => 'perl' }}, { text => { title => { query => 'perl', boost => 2 }}, ] }} SearchBuilder: { content => 'perl', title => { '=' => { query => 'perl', boost=> 2 }} }
1–3 of 3 previous next Post a comment