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 Tommaso Teofili <to...@gmail.com> on 2010/11/04 13:21:10 UTC

querying multiple fields as one

Hi all,
having two fields named 'type' and 'cat' with identical type and options,
but different values recorded, would it be possible to query them as they
were one field?
For instance
 q=type:electronics cat:electronics
should return same results as
 q=common:electronics
I know I could make it defining a third field 'common' with copyFields from
'type' and 'cat' to 'common' but this wouldn't be feasible if you've already
lots of documents in your index and don't want to reindex everything, isn't
it?
Any suggestions?
Thanks in advance,
Tommaso

Re: querying multiple fields as one

Posted by Ken Stanley <do...@gmail.com>.
On Thu, Nov 4, 2010 at 8:21 AM, Tommaso Teofili
<to...@gmail.com>wrote:

> Hi all,
> having two fields named 'type' and 'cat' with identical type and options,
> but different values recorded, would it be possible to query them as they
> were one field?
> For instance
>  q=type:electronics cat:electronics
> should return same results as
>  q=common:electronics
> I know I could make it defining a third field 'common' with copyFields from
> 'type' and 'cat' to 'common' but this wouldn't be feasible if you've
> already
> lots of documents in your index and don't want to reindex everything, isn't
> it?
> Any suggestions?
> Thanks in advance,
> Tommaso
>

Tommaso,

If re-indexing is not feasible/preferred, you might try looking into
creating a dismax handler that should give you what you're looking for in
your query: http://wiki.apache.org/solr/DisMaxQParserPlugin. The same
solrconfig.xml that comes with SOLR has a dismax parser that you can modify
to your needs.

- Ken Stanley

Re: querying multiple fields as one

Posted by Jonathan Rochkind <ro...@jhu.edu>.
Tommaso Teofili wrote:
>
>
> No failing, just looking for how to do such "expansion" of fields
> automatically (with fields in OR but that's not an issue I think)
>   
the dismax query parser is that way.


Re: querying multiple fields as one

Posted by Tommaso Teofili <to...@gmail.com>.
Hi Erick

2010/11/4 Erick Erickson <er...@gmail.com>

> Ken's suggestion to look at dismax is a good one, but I have
> a question
> q=type:electronics cat:electronics
>
> should do what you want assuming your default operator
> is OR.


correct


>  Is it failing? Or is the real question how you can
> do this automatically?
>

No failing, just looking for how to do such "expansion" of fields
automatically (with fields in OR but that's not an issue I think)


>
> I'd expect the ranking to be a bit different, but I'm guessing
> that's not a big issue....
>

right, no problem if the scoring isn't exactly the same.
Thanks,
Tommaso



>
> Best
> Erick
>
> On Thu, Nov 4, 2010 at 8:21 AM, Tommaso Teofili
> <to...@gmail.com>wrote:
>
> > Hi all,
> > having two fields named 'type' and 'cat' with identical type and options,
> > but different values recorded, would it be possible to query them as they
> > were one field?
> > For instance
> >  q=type:electronics cat:electronics
> > should return same results as
> >  q=common:electronics
> > I know I could make it defining a third field 'common' with copyFields
> from
> > 'type' and 'cat' to 'common' but this wouldn't be feasible if you've
> > already
> > lots of documents in your index and don't want to reindex everything,
> isn't
> > it?
> > Any suggestions?
> > Thanks in advance,
> > Tommaso
> >
>

Re: querying multiple fields as one

Posted by Erick Erickson <er...@gmail.com>.
Ken's suggestion to look at dismax is a good one, but I have
a question
q=type:electronics cat:electronics

should do what you want assuming your default operator
is OR.  Is it failing? Or is the real question how you can
do this automatically?

I'd expect the ranking to be a bit different, but I'm guessing
that's not a big issue....

Best
Erick

On Thu, Nov 4, 2010 at 8:21 AM, Tommaso Teofili
<to...@gmail.com>wrote:

> Hi all,
> having two fields named 'type' and 'cat' with identical type and options,
> but different values recorded, would it be possible to query them as they
> were one field?
> For instance
>  q=type:electronics cat:electronics
> should return same results as
>  q=common:electronics
> I know I could make it defining a third field 'common' with copyFields from
> 'type' and 'cat' to 'common' but this wouldn't be feasible if you've
> already
> lots of documents in your index and don't want to reindex everything, isn't
> it?
> Any suggestions?
> Thanks in advance,
> Tommaso
>