I keep hearing that I should be using filters rather than queries
because they are much quicker but I'm not sure how I should be using
them. Up to now I have been using QueryStringQueryBuilder to
generate Lucene syntax string queries.
Here are my questions:
i) If I do a sort should I always be using filters because the sort
removes the relevance ranking and so makes the only advantage of
queries (i.e. relevance score) useless.
ii) Do filters have to be on a basic query to start with?
If ii) is true, what should be my basic Query - should it be a search
on all fields, as above, that is then filtered by fields or should I
also specify the fields in the query?
but I'm not sure how I should be using
them. Up to now I have been using QueryStringQueryBuilder to
generate Lucene syntax string queries.
You can't use filters on a query string search. You have to use a
request body search:
i) If I do a sort should I always be using filters because the sort
removes the relevance ranking and so makes the only advantage of
queries (i.e. relevance score) useless.
If you are not sorting on _score, then yes, rather use filters.
ii) Do filters have to be on a basic query to start with?
If ii) is true, what should be my basic Query - should it be a search
on all fields, as above, that is then filtered by fields or should I
also specify the fields in the query?
I keep hearing that I should be using filters rather than queries
because they are much quicker
and because their results can be cached. Depending on the filter type,
some are cached by default, some are not (see Filter Caching onhttp://www.elasticsearch.org/guide/reference/query-dsl/)
but I'm not sure how I should be using
them. Up to now I have been using QueryStringQueryBuilder to
generate Lucene syntax string queries.
i) If I do a sort should I always be using filters because the sort
removes the relevance ranking and so makes the only advantage of
queries (i.e. relevance score) useless.
If you are not sorting on _score, then yes, rather use filters.
ii) Do filters have to be on a basic query to start with?
If ii) is true, what should be my basic Query - should it be a search
on all fields, as above, that is then filtered by fields or should I
also specify the fields in the query?
Is it possible to use a filter to search for an exact value on a field
as opposed to a simple token match? I used this alot to make joins to
other entities' ids that are not in the index.
e.g. Many contacts are in many lists, means that for contacts I migh
have data like this
I keep hearing that I should be using filters rather than queries
because they are much quicker
and because their results can be cached. Depending on the filter type,
some are cached by default, some are not (see Filter Caching onhttp://www.elasticsearch.org/guide/reference/query-dsl/)
but I'm not sure how I should be using
them. Up to now I have been using QueryStringQueryBuilder to
generate Lucene syntax string queries.
i) If I do a sort should I always be using filters because the sort
removes the relevance ranking and so makes the only advantage of
queries (i.e. relevance score) useless.
If you are not sorting on _score, then yes, rather use filters.
ii) Do filters have to be on a basic query to start with?
If ii) is true, what should be my basic Query - should it be a search
on all fields, as above, that is then filtered by fields or should I
also specify the fields in the query?
Is it possible to use a filter to search for an exact value on a field
as opposed to a simple token match? I used this alot to make joins to
other entities' ids that are not in the index.
e.g. Many contacts are in many lists, means that for contacts I migh
have data like this
i) If I do a sort should I always be using filters because the sort
removes the relevance ranking and so makes the only advantage of
queries (i.e. relevance score) useless.
If you are not sorting on _score, then yes, rather use filters.
ii) Do filters have to be on a basic query to start with?
If ii) is true, what should be my basic Query - should it be a search
on all fields, as above, that is then filtered by fields or should I
also specify the fields in the query?
Is there a performance difference between using a constant scored
query and a filtered query? All of our current queries are generated
as filtered queries and I'm concerned that this might be slower than
the constant score method. Examples:
Is it possible to use a filter to search for an exact value on a field
as opposed to a simple token match? I used this alot to make joins to
other entities' ids that are not in the index.
e.g. Many contacts are in many lists, means that for contacts I migh
have data like this
i) If I do a sort should I always be using filters because the sort
removes the relevance ranking and so makes the only advantage of
queries (i.e. relevance score) useless.
If you are not sorting on _score, then yes, rather use filters.
ii) Do filters have to be on a basic query to start with?
If ii) is true, what should be my basic Query - should it be a search
on all fields, as above, that is then filtered by fields or should I
also specify the fields in the query?
Is it possible to use a filter to search for an exact value on a field
as opposed to a simple token match? I used this alot to make joins to
other entities' ids that are not in the index.
e.g. Many contacts are in many lists, means that for contacts I migh
have data like this
i) If I do a sort should I always be using filters because the sort
removes the relevance ranking and so makes the only advantage of
queries (i.e. relevance score) useless.
If you are not sorting on _score, then yes, rather use filters.
ii) Do filters have to be on a basic query to start with?
If ii) is true, what should be my basic Query - should it be a search
on all fields, as above, that is then filtered by fields or should I
also specify the fields in the query?
Is there a performance difference between using a constant scored
query and a filtered query? All of our current queries are generated
as filtered queries and I'm concerned that this might be slower than
the constant score method. Examples:
Is it possible to use a filter to search for an exact value on a field
as opposed to a simple token match? I used this alot to make joins to
other entities' ids that are not in the index.
e.g. Many contacts are in many lists, means that for contacts I migh
have data like this
i) If I do a sort should I always be using filters because the
sort
removes the relevance ranking and so makes the only advantage of
queries (i.e. relevance score) useless.
If you are not sorting on _score, then yes, rather use filters.
ii) Do filters have to be on a basic query to start with?
If ii) is true, what should be my basic Query - should it be a
search
on all fields, as above, that is then filtered by fields or
should I
also specify the fields in the query?
Is it possible to use a filter to search for an exact value on a field
as opposed to a simple token match? I used this alot to make joins to
other entities' ids that are not in the index.
e.g. Many contacts are in many lists, means that for contacts I migh
have data like this
i) If I do a sort should I always be using filters because the
sort
removes the relevance ranking and so makes the only advantage of
queries (i.e. relevance score) useless.
If you are not sorting on _score, then yes, rather use filters.
ii) Do filters have to be on a basic query to start with?
If ii) is true, what should be my basic Query - should it be a
search
on all fields, as above, that is then filtered by fields or
should I
also specify the fields in the query?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.