Skip to content

Instantly share code, notes, and snippets.

@lcpriest
Created September 6, 2016 14:04
Show Gist options
  • Save lcpriest/369dda8649a16c392612f4d698b889b4 to your computer and use it in GitHub Desktop.
Save lcpriest/369dda8649a16c392612f4d698b889b4 to your computer and use it in GitHub Desktop.
client = ElasticWrapper::Session.new.client
client.search(index: 'test', type: 'contacts', body: body)
body = { query: { bool: { filter: { term: { name: 'lachlan' } } } } }
=>
[{
"_index"=>"test",
"_type"=>"contact",
"_id"=>"1",
"_score"=>1.0,
"_source"=>{
"id"=>2157,
"name"=>"Lachlan Priest"
}
}]
body = { query: { bool: { filter: { term: { name: 'Lachlan' } } } } }
=>
[]
@lcpriest
Copy link
Author

lcpriest commented Sep 8, 2016

Thanks! This was essentially what I was looking for, I've ended up using the keyword tokenizer (though I might just drop this, as it's essentially the same as not_analyzed) and a lowercase filter to allow for case insensitive search.

I ended up doing a static mapping for as many fields as I know in advance and will just look into again every month or so and see if I find any recurring fields in mappings that I didn't define yet.

Thanks for the post - I think the best piece of advice that someone gave was that the ES docs are not really reference docs, they are more like a tutorial. They are much better if you read them like a book and follow the pages; after that everything became a lot clearer.

Again, thank you, this has been really helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment