Filter on "more like this" query?

Hi everyone,

I'm replacing the search on http://jobs.perl.org/ with Elastic
Search. So far everything is working very nicely - it's been a
pleasure to work with (well, except the obscure errors while I was
learning the query syntax).

I loaded all the old/expired jobs into the index, too -- the intention
was to be able to do a "more like this" query to help the user find an
active similar job when requesting details for a job that's expired or
been removed from the site by the poster.

To do this I added an 'active: [0 | 1]' flag to each document and in
regular search I just filter on this; it works great.

However -- I can't figure out how to do the filter on the mlt query.
Is it not possible?

  • ask

Hi Ask

However -- I can't figure out how to do the filter on the mlt query.
Is it not possible?

You are using the /_mlt query?

This just gets converted to a standard search with a more_like_this
query:
http://www.elasticsearch.com/docs/elasticsearch/rest_api/more_like_this/

which you can then wrap in query filter:
http://www.elasticsearch.com/docs/elasticsearch/rest_api/query_dsl/query_filter/

clint

I think that it should be wrapped with a filtered query:
http://www.elasticsearch.com/docs/elasticsearch/rest_api/query_dsl/filtered_query/,
the mlt_query will be the query, and the filter will include the active
ones.

On Mon, Sep 27, 2010 at 9:46 AM, Clinton Gormley clinton@iannounce.co.ukwrote:

Hi Ask

However -- I can't figure out how to do the filter on the mlt query.
Is it not possible?

You are using the /_mlt query?

This just gets converted to a standard search with a more_like_this
query:
http://www.elasticsearch.com/docs/elasticsearch/rest_api/more_like_this/

which you can then wrap in query filter:

http://www.elasticsearch.com/docs/elasticsearch/rest_api/query_dsl/query_filter/

clint

Thanks Shay & Clint:

Yes - I was trying to use the 'mlt' query (with the id of the old
posting). Clint pointed out to me on IRC that I need to do it with a
regular search to combine it with other filters. I changed the code
to just build the "like_text" and pass it in as a regular filter and
all is well now. Thanks!

  • ask

--
http://askask.com/