Sorting on the not analyzed text

Hi,

      I have a  type "*user*" where I am storing the user's data. its 

having one of the column "name" having the mapping of string and *analyzed
*.

Now lets says users have the names as

joe cartano
carter swan

Now my requirement is that if i search for term "cart", then it should
search both of above users, but carter swan should get higher score than
the joe cartano. I can not user the sort clause here, as i need not to sort
it alphabetically, I am using the custom_score_filter to assign external
scoring and i want to give the priority to first name, although first
name and last name are stored together in a single attribute "name".

Can someone help me out this please. This should be a simple sorting issue,
but I can not find the solution except the one where i save first name and
last name separate.

--

Hey Narinder,

If you supplied a gist it would make answering this so much easier but I'll
attempt to answer the best I can:

  1. If you want to sort on the field then you should be doing so on a
    not_analyzed field (either change the mapping to not_analyzed instead of
    analyzed or change it to a multi field with both analyzed and not_analyzed
    properties). I do believe you mentioned that you don't want to sort anyway,
    but I just wanted to mention this anyway.
  2. Is there a reason why you can't split the name into a first_name and
    last_name? If so you could then add a boost to the first_name during
    queries that would push it to the top over last_name matches.
  3. Just an fyi but if you search for "cart" there's no reason why
    elasticsearch would choose one of your example names over the other. I'm
    not sure what analyzers and filters you are using during indexing or if you
    are just using a wildcard during the actually searching but I can't see any
    reason why either would have relevancy over the other.

Hopefully this helps but if not add a gist with your exact scenario and
that should make it fully clear.

On Tue, Sep 11, 2012 at 5:18 AM, Narinder Kaur narinder.kaur@izap.inwrote:

Hi,

      I have a  type "*user*" where I am storing the user's data. its

having one of the column "name" having the mapping of string and *
analyzed*.

Now lets says users have the names as

joe cartano
carter swan

Now my requirement is that if i search for term "cart", then it should
search both of above users, but carter swan should get higher score than
the joe cartano. I can not user the sort clause here, as i need not to sort
it alphabetically, I am using the custom_score_filter to assign external
scoring and i want to give the priority to first name, although first
name and last name are stored together in a single attribute "name".

Can someone help me out this please. This should be a simple sorting
issue, but I can not find the solution except the one where i save first
name and last name separate.

--

--