Posts

Showing posts with the label Elasticsearch

Conditional Sorting In ElasticSearch

Answer : Yes this is possible in ElasticSearch using a script, either for sorting or for scoring. My preference would be for a scoring script because 'script based score' is going to be quicker (according to the documentation). Using a scoring script, you could use the Unix timestamp for the date field of type int/long and an mvel sorting script in the custom_score query. You might need to re-index your documents. You would also need to be able to convert the searched for time into a Unix timestamp to pump it at ElasticSearch. The sorting script would then deduct the requested timestamp from each document's timestamp and make an absolute value. Then the results are sorted in ascending order - the lowest 'distance' is the best. So when looking for documents dated about a year ago, it would look something like: "query": { "custom_score" : { "query" : { .... }, "params" : { ...

Can Not Start Elasticsearch As A Service In Ubuntu 16.04

Answer : I found the solution for this issue. The solution comes from this discussion thread- Can’t start elasticsearch with Ubuntu 16.04 on elastic's website. It seems that to get Elasticsearch to run on 16.04 you have to set START_DAEMON to true on /etc/default/elasticsearch . It comes commented out by default, and uncommenting it makes Elasticsearch start again just fine. Be sure to use systemctl restart instead of just start because the service is started right after installation, and apparently there's some socket/pidfile/something that systemd keeps that must be released before being able to start the service again. The problem lies on log files, "No java runtime was found." Jul 30 18:28:13 dimik elasticsearch[10266]: [warning] /etc/init.d/elasticsearch: No java runtime was found Here's my solution to the problem. Check elasticsearch init file sudo nano /etc/init.d/elasticsearch search for . /usr/share/java-w...