You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Sohail Aboobaker <sa...@gmail.com> on 2012/07/11 07:10:40 UTC

Query by Example

Hi,

Is there a way to search by providing an example document to solr? We would
set the fields of the example document to desired filter and ask Solr to
bring all documents that match this example document. For example, if our
document contains itemnumber, title, sku, price etc. Is it possible to set
a document to price=50 and title='xyz' and then search for all documents
that match this document.

Regards,
Sohail

Re: Query by Example

Posted by Sohail Aboobaker <sa...@gmail.com>.
Thanks. That is what we concluded i.e. to write a wrapper method within our
service to build the query for Solr by examining the example bean.

Thanks again.

Re: Query by Example

Posted by Gora Mohanty <go...@mimirtech.com>.
On 11 July 2012 10:52, Sohail Aboobaker <sa...@gmail.com> wrote:
> Thanks,
>
> I will look into more like this. To answer your question, we were
> discussing interface for a central search service that all other components
> can call. We have to provide a set of parameters as interface which clients
> can set and ask for results. This would mean that name of each parameter
> needs to be defined and mapped to document field for the search service to
> work. One other approach is to publish a bean object which corresponds to
> the schema and have clients set values in the example bean object and ask
> for results matching that bean object. We thought this approach might be
> cleaner than a map of parameters.

Not sure that I understand the advantage of your second approach,
but you should be able to build something on top of SolrJ, e.g., with
an internal  method that translates bean values to a Solr query:
http://wiki.apache.org/solr/Solrj#Reading_Data_from_Solr

Regards,
Gora
Regards,
Gora

Re: Query by Example

Posted by Sohail Aboobaker <sa...@gmail.com>.
Thanks,

I will look into more like this. To answer your question, we were
discussing interface for a central search service that all other components
can call. We have to provide a set of parameters as interface which clients
can set and ask for results. This would mean that name of each parameter
needs to be defined and mapped to document field for the search service to
work. One other approach is to publish a bean object which corresponds to
the schema and have clients set values in the example bean object and ask
for results matching that bean object. We thought this approach might be
cleaner than a map of parameters.

Regards,
Sohail

Re: Query by Example

Posted by Gora Mohanty <go...@mimirtech.com>.
On 11 July 2012 10:40, Sohail Aboobaker <sa...@gmail.com> wrote:
> Hi,
>
> Is there a way to search by providing an example document to solr? We would
> set the fields of the example document to desired filter and ask Solr to
> bring all documents that match this example document. For example, if our
> document contains itemnumber, title, sku, price etc. Is it possible to set
> a document to price=50 and title='xyz' and then search for all documents
> that match this document.

Don't think that's possible, but are you looking for MoreLikeThis:
http://wiki.apache.org/solr/MoreLikeThis

Why would one want the functionality that you describe? If you
know the desired search terms, isn't creating an example document
more onerous than formulating a Solr query?

Regards,
Gora