elasticsearch - find by location based on name - elasticsearch

I'm trying to build a query that match a person's address by name and I'm currently facing this situation:
Assuming I'm looking for people in California, my query for california should match locations like:
California
Mountain View, California
Palo Alto, CA
Currently, full-text search solves the first two very nicely, but I'm not able to find people like in the third example.
Anyone knows if there's a way to do this?
In MySQL I would do a join with another table with location names and so on, would that be possible in ES?
Thanks!

Related

'loosen up' Laravel Scout's search functionality to return more results with database driver

I'm using Laravel Scout with the driver set as database to create a searchable knowlegde base.
The issue i've currently got it that I would like each word in the search term to be searched for an return all results that have any of the words rather than an exact match.
So for example:
search term: pay a bill
database records contain: pay my bill, how to pay a bill, paying my bill
With my current setup, it wont return any of these results as none of them match the exact term searched.
Is there anything I can do in Scout to make it loosely search each word?
I can achieve this by using whereFullText() but I wanted to keep this within Scout and using ::search() if possible.

Places API - returns only results containing a zipcode

I made an autocomplete with Google Places API that returns cities based on a input text value.
Didn't seem that hardest thing to do, but I came across an issue: some results don't have a zipcode. It makes sense if you think about Paris : Paris is a city, but it has more than 20 zipcodes. So if you search for Paris in my autocomplete, you'll have a Paris result, that doesn't have any zipcode (because you have to be more specific). It can also happen with small cities: if you search for Bourgneuf, you'll find a city Bourgneuf without zipcode (maybe because it has homonyms?).
It can be reproduced using Google's example: https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete
So I'm looking for a way to search for cities on Places API and only get results containing zipcode.
Any ideas?

How to make Country-State-City like search in elastic Search

I want to make dependent search like when user type country and select country then on next dropdown/text search result would be from that particular Countries state, after selecting state on next text search would only based on that selected state. can anyone help to achieve this kind thing via elastic search.
i am new to elastic Search and i had basic idea of it, but didn't get idea how to do this kind of stuff where i need to search from child and feel data like map
Fist, it is important to understand how Elasticsearch store its data. You can find this kind of info here: https://www.elastic.co/guide/en/elasticsearch/reference/master/documents-indices.html
So, basically what you need is build a query with two must terms.
One for the object type (Country, State, etc).
Other for the name ("Los Angeles", "Massachussets", etc). If you want a autocomplete feature you could add a wildcard query in your list. https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html
Obs: When you store your State object do not forget to store the Country name together. Since Elasticsearch is non relational you have to have Country name indexed in the State document.
Hope that it helps

Elasticsearch with multiple search criteria

I am try to build a full text search engine using elasticsearch. We have a application which has conferences running across the globe. We have the future and past conferences data. For a POC we have already loaded the conferences details into elasticsearch and it contains fields like title,date,venue,geo_location of the venue as document.
I am able to do simple search using match all query. And also by using function_score I can get the current on going conferences and also using user geo location i can get nearby conferences to users location.
But there are some uses cases where i got stuck and could not proceed. Use cases are.
1) If user try to search with "title + location" then I should not use the user current geo location rather whatever user has provided the city_name use that place geo location and retrieve those doc. Here I know some programming is also required.
2) User search with "title + year", for ex. cardio 2014. User interested to see all the caridology conf of 2014 and it should retrieve that year documents only. But using function score it is retrieving the current years documents.
First of all let me know that above two use cases can be handled in single query. I am thinking to handle it one request, but got stuck.
A proper solution would require you to write your own query parser in your application (outside of elasticsearch) that will parse the query and extract dates, locations, etc. Once all features are extracted, the parser should generate a bool query where each feature would become an appropriate must clause. So, the date would became a range query, the location - geo_location query and everything else would go into a match query for full text matching. Then this query can be sent to elasticsearch.

ElasticSearch bulk update

Say we have an documents to index all students information (fields city & name) .
At a point If I want to update city of all students with prefix like "NY -" all in one strech. Can this be done?
eg:
David Auburn
Jack Jamestown
Claire Newburgh
Now I need an Single API or ES call which changes all the above documents to
eg:
David NY-Auburn
Jack NY-Jamestown
Claire NY-Newburgh
I know there is way we can do it one update for each document. but i need ALL DOCUMENTS IN ONE GO
Thanks
Mahesh
Update by query does not exist in ES. I don'think the underlying lucene indices have a way to update, they delete and re-add always.
There is some talk about it becoming a thing, maybe in 1.0?
There is a plugin that can do update by query
You could write a quick script to read and re-post all your docs using any of the ES clients.

Resources