Custom score in Elastic Search

Hi all,

I would like to search in my ES DB and return the results according to some
customer score.
Is it possible, if yes, what's the best way to do it, and what would be the
runtime consequences?

Case A:
I have an index, where each document represents a class, with list of
students and a list of teachers.

{
"properties" : {
"students" : {
"include_in_root" : 1,
"type" : "nested",
"properties" : {
"name" : {
"first" : "text",
"last" : "text",
},
},
"email" : { "type" : "string", "index" : "not_analyzed" },
},

"teachers" : {
    "include_in_root" : 0,
    "include_in_all" : 0,
    "type" : "nested",
    "properties" : {
        "name" : {
            "title" : { "type" : "string", "index" : "not_analyzed" },
            "first" : "text",
            "last" : "text",
            },
        },
    },
},

}

I would like to influence Elastic Search score function, such that it will
give higher score to documents with matched techers.

For example, if I have search for "Smith", I would like the documents with *
teacher* Smith be with higher score than documents with students Smith.

Case B:

Same mapping as in Case A, but now I would like to give a higher score to
teachers with title "Dr" or "Prof".

Thanks a lot!

Dmitry.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Use a bool query to run two nested queries: one on students and one on
teachers, and boost the teachers query over the students query

clint

On 21 May 2013 13:34, Dmitry Babitsky dimok21@gmail.com wrote:

Hi all,

I would like to search in my ES DB and return the results according to
some customer score.
Is it possible, if yes, what's the best way to do it, and what would be
the runtime consequences?

Case A:
I have an index, where each document represents a class, with list of
students and a list of teachers.

{
"properties" : {
"students" : {
"include_in_root" : 1,
"type" : "nested",
"properties" : {
"name" : {
"first" : "text",
"last" : "text",
},
},
"email" : { "type" : "string", "index" : "not_analyzed" },
},

"teachers" : {
    "include_in_root" : 0,
    "include_in_all" : 0,
    "type" : "nested",
    "properties" : {
        "name" : {
            "title" : { "type" : "string", "index" : "not_analyzed" },
            "first" : "text",
            "last" : "text",
            },
        },
    },
},

}

I would like to influence Elastic Search score function, such that it will
give higher score to documents with matched techers.

For example, if I have search for "Smith", I would like the documents with
teacher Smith be with higher score than documents with students Smith.

Case B:

Same mapping as in Case A, but now I would like to give a higher score to
teachers with title "Dr" or "Prof".

Thanks a lot!

Dmitry.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks a lot!!!

One more question - suppose each teacher and each student have some rank
from 0 to 100.
Is is possible to influence the Elastic Search score to take into account
the student/teacher rank (in addition to the default matching score)?

Thanks again,
Dmitry.

On Thursday, May 23, 2013 12:48:10 PM UTC+3, Clinton Gormley wrote:

Use a bool query to run two nested queries: one on students and one on
teachers, and boost the teachers query over the students query

clint

On 21 May 2013 13:34, Dmitry Babitsky <dim...@gmail.com <javascript:>>wrote:

Hi all,

I would like to search in my ES DB and return the results according to
some customer score.
Is it possible, if yes, what's the best way to do it, and what would be
the runtime consequences?

Case A:
I have an index, where each document represents a class, with list of
students and a list of teachers.

{
"properties" : {
"students" : {
"include_in_root" : 1,
"type" : "nested",
"properties" : {
"name" : {
"first" : "text",
"last" : "text",
},
},
"email" : { "type" : "string", "index" : "not_analyzed" },
},

"teachers" : {
    "include_in_root" : 0,
    "include_in_all" : 0,
    "type" : "nested",
    "properties" : {
        "name" : {
            "title" : { "type" : "string", "index" : "not_analyzed" },
            "first" : "text",
            "last" : "text",
            },
        },
    },
},

}

I would like to influence Elastic Search score function, such that it
will give higher score to documents with matched techers.

For example, if I have search for "Smith", I would like the documents
with teacher Smith be with higher score than documents with students
Smith.

Case B:

Same mapping as in Case A, but now I would like to give a higher score to
teachers with title "Dr" or "Prof".

Thanks a lot!

Dmitry.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Yes - look at using a script in a custom_score query on the nested docs

c

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Clinton,

Again, many thanks for your help!

Now I ran into another problem.
If I search for two words-expression (for example: "James Bond"), Elastic
Search returns all the classes where James Bond either studies or teaches.

However, I would like to get the documents where one of the word (James)
matches in students, and the other (Bond) matches in teachers (or vice
versa).

Is there any way to do it in Elastic Search?

Thanks,
Dmitry.

On Thursday, May 23, 2013 12:48:10 PM UTC+3, Clinton Gormley wrote:

Use a bool query to run two nested queries: one on students and one on
teachers, and boost the teachers query over the students query

clint

On 21 May 2013 13:34, Dmitry Babitsky <dim...@gmail.com <javascript:>>wrote:

Hi all,

I would like to search in my ES DB and return the results according to
some customer score.
Is it possible, if yes, what's the best way to do it, and what would be
the runtime consequences?

Case A:
I have an index, where each document represents a class, with list of
students and a list of teachers.

{
"properties" : {
"students" : {
"include_in_root" : 1,
"type" : "nested",
"properties" : {
"name" : {
"first" : "text",
"last" : "text",
},
},
"email" : { "type" : "string", "index" : "not_analyzed" },
},

"teachers" : {
    "include_in_root" : 0,
    "include_in_all" : 0,
    "type" : "nested",
    "properties" : {
        "name" : {
            "title" : { "type" : "string", "index" : "not_analyzed" },
            "first" : "text",
            "last" : "text",
            },
        },
    },
},

}

I would like to influence Elastic Search score function, such that it
will give higher score to documents with matched techers.

For example, if I have search for "Smith", I would like the documents
with teacher Smith be with higher score than documents with students
Smith.

Case B:

Same mapping as in Case A, but now I would like to give a higher score to
teachers with title "Dr" or "Prof".

Thanks a lot!

Dmitry.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.