Query is slow!


(yuxiaobing) #1

My query hits too many results,and I just need any ten terms,but elasticsearch will sort all the hited terms by relevancy.
Is there a method I can forbidden this feature?


(Ashwin Amit) #2

Look into using filter instead of query? You might want something like https://www.elastic.co/guide/en/elasticsearch/reference/1.4/query-dsl-terms-filter.html


(yuxiaobing) #3

Thank you for your answer.I think the sort process is after the query and the filter, I want forbidden it.


(Ashwin Amit) #4

Filter is not sorted by relevance, query is.


(yuxiaobing) #5

the sort process is after query and filters before return results.that is query&filter -> sort -> return results.


(Ashwin Amit) #6

Please have you tried a filter? Filter does not score relevance. Are you running vs an analyzed or non analyzed field?

https://www.elastic.co/guide/en/elasticsearch/guide/current/_queries_and_filters.html


(yuxiaobing) #7

I had tried it on analyzed field,but slowly too.the more docs the query&filter htis, the slower the query&filter.But I only want ten docs it hits,so I think the time is constant.


(Ashwin Amit) #8

It depends on what you're trying to do. Are you basically trying to do a search for basically key=value?

e.g. request.verb: "HEAD"?

Then you can maybe use a non-analyzed field and a term filter. If you're trying to do some search against an analyzed field your options for speeding up query may be more limited besides throwing more resource at the search.

If you could paste your exact query (or some general form) would be a lot more helpful.


(Ivan Brusic) #9

Wrapping the query in a constant score query will provide a uniform score,
but you will have no control over what elements will appear in the top 10.
It is not like a RDBMS where the rows are returned by their place in the
index.

https://www.elastic.co/guide/en/elasticsearch/reference/master/query-dsl-constant-score-query.html

Ivan


(system) #10