39571

Elasticsearch with mutilple search criteria

Question:

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.

Any help.

Answer1:

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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html" rel="nofollow">bool</a> 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.

Recommend

  • Weighted search on one field and a normal search on other field
  • Custom scoring function in Elasticsearch does not return expected field value
  • When using gauss decay score funtion, it always scores 1 on nested elements
  • Geospatial Index for inner structure
  • How can I programmatically check whether geo-tagging is enabled?
  • Geo Fix not working in Android SDK 2.2
  • PyQt4 application on Windows is crashing on exit
  • sudo easy_install for SimpleITK not that easy
  • If I am creating a simple client server application in IntelliJ, how should this work?
  • crash in __tcf_0
  • How to add closing tag for canvas in three js rendered Canvas?
  • Examples of how to a STS in .Net 4.5 using WCF
  • there is no graph with tensorboard
  • CSS bleed-through with cfinput type=“datefield”
  • R Split data.frame using a column that represents and on/off switch
  • Can I programmatically choose the Android layout folder?
  • Not able to aggregate on nested fields in elasticsearch
  • Unable to install Git-core+svn by MacPorts
  • Django simple Captcha “No module named fields” error
  • How do I get HTML corresponding to current DOM tree?
  • JQuery Internet Explorer and ajaxstop
  • Can you perform a UNION without a subquery in SQLAlchemy?
  • JSON response opens as a file, but I can't access it with JavaScript
  • Could not find rake using whenever rails
  • PostgreSQL Query without WHERE only ORDER BY and LIMIT doesn't use index
  • MongoDB in PHP using aggregate to group by _id is null not working
  • How to get address from latitude and longitude android google map v2 [duplicate]
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Change an a tag attribute in JavaScript based on screen width
  • Display Images one by one with next and previous functionality
  • PHP: When would you need the self:: keyword?
  • SQL merge duplicate rows and join values that are different
  • Acquiring multiple attributes from .xml file in c#
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • Authorize attributes not working in MVC 4
  • Busy indicator not showing up in wpf window [duplicate]
  • reshape alternating columns in less time and using less memory
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF
  • How can I use threading to 'tick' a timer to be accessed by other threads?