0
votes

I have a Rails application with term => definitions stored in nodes on Neo4j that I want my users to search using elastic search. Through usage we've found they far more commonly want to find the term name first before they want to search the description. But I'm having trouble finding the function that returns results for a certain field first over other fields.

[
    {
      "id": 1,
      "data": {
        "name": "Foo",
        "description": "Something super awesome."
      }
    },
    {
      "id": 2,
      "data": {
        "name": "Bar",
        "description": "Something that depends on Foo"
      }
    }
]


search for "Foo"

Because both terms contain the word Foo in either name or description, my app returns both in alphabetical order and since Bar is alphabetically before Foo, Bar appears first. This can get very tiring when my users search for a common term used in many other terms.

How do I return results from the name field first followed by the secondary results in the description?

I have a feeling this has more to do with neo4j than elastic search

1
Could you give us an idea of what gems you're using and how everything is setup? Are you using Elasticsearch directly or something like Searchkick?subvertallchris

1 Answers

0
votes

Its possible by Adding term and fields frequency value to your type mapping. http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/scoring-theory.html name": { "type": "string", "store": true, "norms": { "enabled": false }, "index_options": "docs" }

let me known any queries.