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 "Øystein F. Steimler" <oy...@easyconnect.no> on 2009/09/28 14:17:27 UTC

q.alt matching no documents

Hi, list!

I want to add a q.alt matching no documents in my dismax handler to serve a 
consistent reply to a client application.

Without a q.alt, a missing q from the client will cause an "missing query 
string" error. With a q.alt matching no document I will be able to respond 
with an empty result set when no query is supplied.

I've been using q.alt=-*:* because *:* is said to be the most efficient way of 
querying for every document. is -*:* the most efficient way of querying for 
no document?

.øs

-- 
Øystein Steimler, Produktans, EasyConnect AS  -  http://1890.no
oystein.steimler@easyconnect.no  - GPG: 0x784a7dea - Mob: 90010882

Re: q.alt matching no documents

Posted by Erik Hatcher <er...@gmail.com>.
Note that whatever query you use will be cached in the query cache.  - 
*:* is likely the best choice.   Another alternative if you've got  
dynamic fields wired in, is something like  
_nonexistent_field_s:dummy_value

	Erik


On Sep 28, 2009, at 5:17 AM, Øystein F. Steimler wrote:

> Hi, list!
>
> I want to add a q.alt matching no documents in my dismax handler to  
> serve a
> consistent reply to a client application.
>
> Without a q.alt, a missing q from the client will cause an "missing  
> query
> string" error. With a q.alt matching no document I will be able to  
> respond
> with an empty result set when no query is supplied.
>
> I've been using q.alt=-*:* because *:* is said to be the most  
> efficient way of
> querying for every document. is -*:* the most efficient way of  
> querying for
> no document?
>
> .øs
>
> -- 
> Øystein Steimler, Produktans, EasyConnect AS  -  http://1890.no
> oystein.steimler@easyconnect.no  - GPG: 0x784a7dea - Mob: 90010882


Re: q.alt matching no documents

Posted by Chris Hostetter <ho...@fucit.org>.
: I've been using q.alt=-*:* because *:* is said to be the most efficient way of 
: querying for every document. is -*:* the most efficient way of querying for 
: no document?

I don't think so ... solr internally reverse pure negative queries so that 
they are combined with a matchalldocsquery that is positive ... which 
means your final query would look like (*:* -*:*) ... there's no toehr 
query optimization that would happen, so that query sould produce a 
DisjunctionScorer that can't ever "skipTo" past any docs.

once it gets cached it shouldn't matter -- but hey, you asked.

The most efficient way i can think of (besides a new Query class like John 
suggested) is along the lines of what Erik mentioned...

    <fieldtype name="ignored" stored="false" indexed="false" multiValued="true" class="solr.StrField" /> 
    <field name="match_nothing" type="ignored"/>
    ...
    q.alt=match_nothing:0

...it has to be a real field or the query parsing code will freak out, but 
making it indexed=false will ensure that there will *never* be any terms 
in that field so the term "0" will never be there so the entire query 
process will short circut out almost immediately (it won't even construct 
a Scorer let alone iterate over any docs)

-Hoss


Re: q.alt matching no documents

Posted by John Wang <jo...@gmail.com>.
patch created for lucene:

https://issues.apache.org/jira/browse/LUCENE-1931

I am not sure what the right thing to do here is to hook it into
QueryParser.java.

Maybe the Solr people can comment on how to hook it into Solr.

-John

On Mon, Sep 28, 2009 at 6:31 AM, John Wang <jo...@gmail.com> wrote:

> You can actually write a NoHitsQuery implementation,it is rather simple. If
> you like, I can create a issue and attach a patch.
>
> -John
>
>
> On Mon, Sep 28, 2009 at 5:17 AM, Øystein F. Steimler <
> oystein@easyconnect.no> wrote:
>
>> Hi, list!
>>
>> I want to add a q.alt matching no documents in my dismax handler to serve
>> a
>> consistent reply to a client application.
>>
>> Without a q.alt, a missing q from the client will cause an "missing query
>> string" error. With a q.alt matching no document I will be able to respond
>> with an empty result set when no query is supplied.
>>
>> I've been using q.alt=-*:* because *:* is said to be the most efficient
>> way of
>> querying for every document. is -*:* the most efficient way of querying
>> for
>> no document?
>>
>> .øs
>>
>> --
>> Øystein Steimler, Produktans, EasyConnect AS  -  http://1890.no
>> oystein.steimler@easyconnect.no  - GPG: 0x784a7dea - Mob: 90010882
>>
>
>

Re: q.alt matching no documents

Posted by John Wang <jo...@gmail.com>.
patch created for lucene:

https://issues.apache.org/jira/browse/LUCENE-1931

I am not sure what the right thing to do here is to hook it into
QueryParser.java.

Maybe the Solr people can comment on how to hook it into Solr.

-John

On Mon, Sep 28, 2009 at 6:31 AM, John Wang <jo...@gmail.com> wrote:

> You can actually write a NoHitsQuery implementation,it is rather simple. If
> you like, I can create a issue and attach a patch.
>
> -John
>
>
> On Mon, Sep 28, 2009 at 5:17 AM, Øystein F. Steimler <
> oystein@easyconnect.no> wrote:
>
>> Hi, list!
>>
>> I want to add a q.alt matching no documents in my dismax handler to serve
>> a
>> consistent reply to a client application.
>>
>> Without a q.alt, a missing q from the client will cause an "missing query
>> string" error. With a q.alt matching no document I will be able to respond
>> with an empty result set when no query is supplied.
>>
>> I've been using q.alt=-*:* because *:* is said to be the most efficient
>> way of
>> querying for every document. is -*:* the most efficient way of querying
>> for
>> no document?
>>
>> .øs
>>
>> --
>> Øystein Steimler, Produktans, EasyConnect AS  -  http://1890.no
>> oystein.steimler@easyconnect.no  - GPG: 0x784a7dea - Mob: 90010882
>>
>
>

Re: q.alt matching no documents

Posted by John Wang <jo...@gmail.com>.
You can actually write a NoHitsQuery implementation,it is rather simple. If
you like, I can create a issue and attach a patch.

-John

On Mon, Sep 28, 2009 at 5:17 AM, Øystein F. Steimler <oystein@easyconnect.no
> wrote:

> Hi, list!
>
> I want to add a q.alt matching no documents in my dismax handler to serve a
> consistent reply to a client application.
>
> Without a q.alt, a missing q from the client will cause an "missing query
> string" error. With a q.alt matching no document I will be able to respond
> with an empty result set when no query is supplied.
>
> I've been using q.alt=-*:* because *:* is said to be the most efficient way
> of
> querying for every document. is -*:* the most efficient way of querying for
> no document?
>
> .øs
>
> --
> Øystein Steimler, Produktans, EasyConnect AS  -  http://1890.no
> oystein.steimler@easyconnect.no  - GPG: 0x784a7dea - Mob: 90010882
>