rubygems.org is now using Elasticsearch With it’s first release on 8 February, 2010, elasticsearch is so old it almost feels nostalgic. Today, elasticsearch is used by thousands of companies for full text search, auto completion, and . log processing analytics Rubygems.org’s search functionality was not up to the mark. One must not have high hopes while using anyway. It was slow, inept and you could only search for names. The is, at the very least, way faster. LIKE operator rubygem new search I would consider it an achievement for elasticsearch that once I went through and watched , I was able to make meaningful changes to the existing implementation. Also, docs with usage examples are the best kind of docs ❤ their documentation a couple of videos Search multiple fields By default, queries will be matched against name, description and summary of gems. Each matched result has a relevance score, which is determined by following three factors: - More often the query term appears in name, description or summary, higher is the relevance score. Term Frequency - Terms that appear in many documents (words like the, a, gems etc) get lower score than more uncommon terms. Inverse Document Frequency - Match in longer fields like summary and description get lower score than name. ( ) Field length norm Read more Geek And Poke It gets better ;) We are using gem downloads to boost search results’ score. It ensures that popular and community approved gems rank higher on the search page. support came just in time for us to update our instance before we switch to using it. Elasticsearch 5 has made some in it’s relevance scoring. Amazon elasticsearch service’s Elasticsearch 5 nifty improvements Filter and advanced search page In elasticsearch, query string supports a mini-language of its own, which can be used to customize your query. Filter options presented on search page already provide useful defaults to limit your search just to match name, description, summary, updated in last one week or in last one month. on rubygems.org Search active You can use and operator to combine your query terms. Query string also supports , , , and . Check out our when you are in mood for a little experimentation. AND OR wildcards fuzziness ranges boosting much more advanced search page Suggestions and analyzers Have you been feeling too lazy to type all the characters of your query correctly? Fear not! Elasticsearch suggestions have your back. When no matching results are found, the search page will suggest queries you probably wanted to type. on rubygems.org Search raols Elasticsearch’s have sensible defaults and can be used directly. Analyzers ensure that when you search for , you get the same result back. We use analyzer over name and analyzer over summary and description. prepackaged analyzers rails async, async rails or async-rail pattern english Road behind I am not exactly proud of . In name of desperate measure for desperate situation, I wrote which returns two values ಠ_ಠ the code we ended up with a method There were moments when I either fumbled myself into the correct solution or got after being stuck. something new on your own comes with its opportunities and struggles. crucial help Learning Elasticsearch came in handy while tracking scoring issues. The on elasticsearch-rails is a great resource for reference. The elasticsearch-model gem also has . explain API rails application templates some nice examples Road ahead A considerable amount of work is yet to be done. We are yet to switch rubygem.org search api to elasticsearch. We already have for adding autocomplete to the search field, however I am a bit skeptical about use of . I am not sure if we need a when can be written with much less code. a PR typehead.js suggestion engine something usable Feel free to hit up if you encounter any issue or have suggestions for improvement. our issue board