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 Gabriele Kahlout <ga...@mysimpatico.com> on 2011/07/09 12:22:24 UTC

What's the fq= syntax for NumericRangeFilter?

I'm trying to filter a query by the value of a numeric field. I can do it in
Java as follows, but I don't know how to do it with the query syntax, and I
found no documentation of it.

@Test
    public void testFqWc() throws Exception {
        IndexSearcher searcher = wc();
*        Filter wc3 = NumericRangeFilter.newIntRange(wc, 3, 3, true, true);*
        final MatchAllDocsQuery allQ = new MatchAllDocsQuery();
        TopDocs allDocs = searcher.search(allQ, 10);
        assertEquals(1, allDocs.totalHits);
        int wc =
Integer.parseInt(searcher.doc(allDocs.scoreDocs[0].doc).get(this.wc));
        assertEquals(3,wc);
        TopDocs docs = searcher.search(allQ, wc3, 10);
        assertEquals(allDocs.totalHits, docs.totalHits);
    }

On Sun, Jun 19, 2011 at 12:43 PM, Ahmet Arslan <io...@yahoo.com> wrote:

> > Beside creating an index with just the site in question, is
> > it possible like
> > with Google to search for results only in a given domain?
>
> If you have an appropriate field that is indexed, yes. fq=site:foo.com
> http://wiki.apache.org/solr/CommonQueryParameters#fq
>



-- 
Regards,
K. Gabriele

--- unchanged since 20/9/10 ---
P.S. If the subject contains "[LON]" or the addressee acknowledges the
receipt within 48 hours then I don't resend the email.
subject(this) ∈ L(LON*) ∨ ∃x. (x ∈ MyInbox ∧ Acknowledges(x, this) ∧ time(x)
< Now + 48h) ⇒ ¬resend(I, this).

If an email is sent by a sender that is not a trusted contact or the email
does not contain a valid code then the email is not received. A valid code
starts with a hyphen and ends with "X".
∀x. x ∈ MyInbox ⇒ from(x) ∈ MySafeSenderList ∨ (∃y. y ∈ subject(x) ∧ y ∈
L(-[a-z]+[0-9]X)).

Re: What's the fq= syntax for NumericRangeFilter?

Posted by Gabriele Kahlout <ga...@mysimpatico.com>.
This was my problem:
        <fieldType name="int" class="solr.TrieIntField" omitNorms="true"/>

I had taken my queu from Nutch's schema:
<fieldType name="long" class="solr.LongField" omitNorms="true"/>


On Sat, Jul 9, 2011 at 4:55 PM, Yonik Seeley <yo...@lucidimagination.com>wrote:

> Something is wrong with your indexing.
> Is "wc" an indexed field?  If not, change it so it is, then re-index your
> data.
>
> If so, I'd recommend starting with the example data and filter for
> something like popularity:[6 TO 10] to convince yourself it works,
> then figuring out what you did differently in your schema/data.
>
> -Yonik
> http://www.lucidimagination.com
>
> On Sat, Jul 9, 2011 at 10:50 AM, Gabriele Kahlout
> <ga...@mysimpatico.com> wrote:
> > http://localhost:8080/solr/select?indent=on&version=2.2&q=*%3A**
> > &fq=wc%3A%5B255+TO+257%5D*
> > &start=0&rows=10&fl=*%2Cscore&qt=&wt=xml&explainOther=&hl.fl=
> >
> > The toString of the request:
> >
> {explainOther=&fl=*,score&indent=on&start=0&q=*:*&hl.fl=&qt=&wt=xml&fq=wc:[255+TO+257]&rows=10000&version=2.2}
> >
> > Even when the FilterQuery is constructed in Java it doesn't work (i get
> > results that ignore the filter query completely).
> >
> >
> > On Sat, Jul 9, 2011 at 3:40 PM, Ahmet Arslan <io...@yahoo.com> wrote:
> >
> >> > I don't get it to work!
> >> >
> >> > If I specify no fq I get the first result with <int
> >> > name="wc">256</int>
> >> >
> >> > With wc:[255 TO 257] (fq=wc%3A%5B255+TO+257%5D) nothing
> >> > comes out.
> >>
> >> If you give us the Full URL you are using, it can be helpful.
> >>
> >> Correct syntax is &fq=wc:[255 TO 257]
> >>
> >> You can use more that fq in a request.
> >>
> >>
> >
> >
> > --
> > Regards,
> > K. Gabriele
> >
> > --- unchanged since 20/9/10 ---
> > P.S. If the subject contains "[LON]" or the addressee acknowledges the
> > receipt within 48 hours then I don't resend the email.
> > subject(this) ∈ L(LON*) ∨ ∃x. (x ∈ MyInbox ∧ Acknowledges(x, this) ∧
> time(x)
> > < Now + 48h) ⇒ ¬resend(I, this).
> >
> > If an email is sent by a sender that is not a trusted contact or the
> email
> > does not contain a valid code then the email is not received. A valid
> code
> > starts with a hyphen and ends with "X".
> > ∀x. x ∈ MyInbox ⇒ from(x) ∈ MySafeSenderList ∨ (∃y. y ∈ subject(x) ∧ y ∈
> > L(-[a-z]+[0-9]X)).
> >
>



-- 
Regards,
K. Gabriele

--- unchanged since 20/9/10 ---
P.S. If the subject contains "[LON]" or the addressee acknowledges the
receipt within 48 hours then I don't resend the email.
subject(this) ∈ L(LON*) ∨ ∃x. (x ∈ MyInbox ∧ Acknowledges(x, this) ∧ time(x)
< Now + 48h) ⇒ ¬resend(I, this).

If an email is sent by a sender that is not a trusted contact or the email
does not contain a valid code then the email is not received. A valid code
starts with a hyphen and ends with "X".
∀x. x ∈ MyInbox ⇒ from(x) ∈ MySafeSenderList ∨ (∃y. y ∈ subject(x) ∧ y ∈
L(-[a-z]+[0-9]X)).

Re: What's the fq= syntax for NumericRangeFilter?

Posted by Yonik Seeley <yo...@lucidimagination.com>.
Something is wrong with your indexing.
Is "wc" an indexed field?  If not, change it so it is, then re-index your data.

If so, I'd recommend starting with the example data and filter for
something like popularity:[6 TO 10] to convince yourself it works,
then figuring out what you did differently in your schema/data.

-Yonik
http://www.lucidimagination.com

On Sat, Jul 9, 2011 at 10:50 AM, Gabriele Kahlout
<ga...@mysimpatico.com> wrote:
> http://localhost:8080/solr/select?indent=on&version=2.2&q=*%3A**
> &fq=wc%3A%5B255+TO+257%5D*
> &start=0&rows=10&fl=*%2Cscore&qt=&wt=xml&explainOther=&hl.fl=
>
> The toString of the request:
> {explainOther=&fl=*,score&indent=on&start=0&q=*:*&hl.fl=&qt=&wt=xml&fq=wc:[255+TO+257]&rows=10000&version=2.2}
>
> Even when the FilterQuery is constructed in Java it doesn't work (i get
> results that ignore the filter query completely).
>
>
> On Sat, Jul 9, 2011 at 3:40 PM, Ahmet Arslan <io...@yahoo.com> wrote:
>
>> > I don't get it to work!
>> >
>> > If I specify no fq I get the first result with <int
>> > name="wc">256</int>
>> >
>> > With wc:[255 TO 257] (fq=wc%3A%5B255+TO+257%5D) nothing
>> > comes out.
>>
>> If you give us the Full URL you are using, it can be helpful.
>>
>> Correct syntax is &fq=wc:[255 TO 257]
>>
>> You can use more that fq in a request.
>>
>>
>
>
> --
> Regards,
> K. Gabriele
>
> --- unchanged since 20/9/10 ---
> P.S. If the subject contains "[LON]" or the addressee acknowledges the
> receipt within 48 hours then I don't resend the email.
> subject(this) ∈ L(LON*) ∨ ∃x. (x ∈ MyInbox ∧ Acknowledges(x, this) ∧ time(x)
> < Now + 48h) ⇒ ¬resend(I, this).
>
> If an email is sent by a sender that is not a trusted contact or the email
> does not contain a valid code then the email is not received. A valid code
> starts with a hyphen and ends with "X".
> ∀x. x ∈ MyInbox ⇒ from(x) ∈ MySafeSenderList ∨ (∃y. y ∈ subject(x) ∧ y ∈
> L(-[a-z]+[0-9]X)).
>

Re: What's the fq= syntax for NumericRangeFilter?

Posted by Gabriele Kahlout <ga...@mysimpatico.com>.
http://localhost:8080/solr/select?indent=on&version=2.2&q=*%3A**
&fq=wc%3A%5B255+TO+257%5D*
&start=0&rows=10&fl=*%2Cscore&qt=&wt=xml&explainOther=&hl.fl=

The toString of the request:
{explainOther=&fl=*,score&indent=on&start=0&q=*:*&hl.fl=&qt=&wt=xml&fq=wc:[255+TO+257]&rows=10000&version=2.2}

Even when the FilterQuery is constructed in Java it doesn't work (i get
results that ignore the filter query completely).


On Sat, Jul 9, 2011 at 3:40 PM, Ahmet Arslan <io...@yahoo.com> wrote:

> > I don't get it to work!
> >
> > If I specify no fq I get the first result with <int
> > name="wc">256</int>
> >
> > With wc:[255 TO 257] (fq=wc%3A%5B255+TO+257%5D) nothing
> > comes out.
>
> If you give us the Full URL you are using, it can be helpful.
>
> Correct syntax is &fq=wc:[255 TO 257]
>
> You can use more that fq in a request.
>
>


-- 
Regards,
K. Gabriele

--- unchanged since 20/9/10 ---
P.S. If the subject contains "[LON]" or the addressee acknowledges the
receipt within 48 hours then I don't resend the email.
subject(this) ∈ L(LON*) ∨ ∃x. (x ∈ MyInbox ∧ Acknowledges(x, this) ∧ time(x)
< Now + 48h) ⇒ ¬resend(I, this).

If an email is sent by a sender that is not a trusted contact or the email
does not contain a valid code then the email is not received. A valid code
starts with a hyphen and ends with "X".
∀x. x ∈ MyInbox ⇒ from(x) ∈ MySafeSenderList ∨ (∃y. y ∈ subject(x) ∧ y ∈
L(-[a-z]+[0-9]X)).

Re: What's the fq= syntax for NumericRangeFilter?

Posted by Ahmet Arslan <io...@yahoo.com>.
> I don't get it to work!
> 
> If I specify no fq I get the first result with <int
> name="wc">256</int>
> 
> With wc:[255 TO 257] (fq=wc%3A%5B255+TO+257%5D) nothing
> comes out.

If you give us the Full URL you are using, it can be helpful.

Correct syntax is &fq=wc:[255 TO 257]

You can use more that fq in a request.


Re: What's the fq= syntax for NumericRangeFilter?

Posted by Gabriele Kahlout <ga...@mysimpatico.com>.
I don't get it to work!

If I specify no fq I get the first result with <int name="wc">256</int>

With wc:[255 TO 257] (fq=wc%3A%5B255+TO+257%5D) nothing comes out.

On Sat, Jul 9, 2011 at 12:29 PM, Markus Jelsma
<ma...@openindex.io>wrote:

> Hu? It's describe in the link Ahmet's given you.
>
> > I'm trying to filter a query by the value of a numeric field. I can do it
> > in Java as follows, but I don't know how to do it with the query syntax,
> > and I found no documentation of it.
> >
> > @Test
> >     public void testFqWc() throws Exception {
> >         IndexSearcher searcher = wc();
> > *        Filter wc3 = NumericRangeFilter.newIntRange(wc, 3, 3, true,
> > true);* final MatchAllDocsQuery allQ = new MatchAllDocsQuery();
> >         TopDocs allDocs = searcher.search(allQ, 10);
> >         assertEquals(1, allDocs.totalHits);
> >         int wc =
> > Integer.parseInt(searcher.doc(allDocs.scoreDocs[0].doc).get(this.wc));
> >         assertEquals(3,wc);
> >         TopDocs docs = searcher.search(allQ, wc3, 10);
> >         assertEquals(allDocs.totalHits, docs.totalHits);
> >     }
> >
> > On Sun, Jun 19, 2011 at 12:43 PM, Ahmet Arslan <io...@yahoo.com>
> wrote:
> > > > Beside creating an index with just the site in question, is
> > > > it possible like
> > > > with Google to search for results only in a given domain?
> > >
> > > If you have an appropriate field that is indexed, yes. fq=site:foo.com
> > > http://wiki.apache.org/solr/CommonQueryParameters#fq
>



-- 
Regards,
K. Gabriele

--- unchanged since 20/9/10 ---
P.S. If the subject contains "[LON]" or the addressee acknowledges the
receipt within 48 hours then I don't resend the email.
subject(this) ∈ L(LON*) ∨ ∃x. (x ∈ MyInbox ∧ Acknowledges(x, this) ∧ time(x)
< Now + 48h) ⇒ ¬resend(I, this).

If an email is sent by a sender that is not a trusted contact or the email
does not contain a valid code then the email is not received. A valid code
starts with a hyphen and ends with "X".
∀x. x ∈ MyInbox ⇒ from(x) ∈ MySafeSenderList ∨ (∃y. y ∈ subject(x) ∧ y ∈
L(-[a-z]+[0-9]X)).

Re: What's the fq= syntax for NumericRangeFilter?

Posted by Markus Jelsma <ma...@openindex.io>.
Hu? It's describe in the link Ahmet's given you.

> I'm trying to filter a query by the value of a numeric field. I can do it
> in Java as follows, but I don't know how to do it with the query syntax,
> and I found no documentation of it.
> 
> @Test
>     public void testFqWc() throws Exception {
>         IndexSearcher searcher = wc();
> *        Filter wc3 = NumericRangeFilter.newIntRange(wc, 3, 3, true,
> true);* final MatchAllDocsQuery allQ = new MatchAllDocsQuery();
>         TopDocs allDocs = searcher.search(allQ, 10);
>         assertEquals(1, allDocs.totalHits);
>         int wc =
> Integer.parseInt(searcher.doc(allDocs.scoreDocs[0].doc).get(this.wc));
>         assertEquals(3,wc);
>         TopDocs docs = searcher.search(allQ, wc3, 10);
>         assertEquals(allDocs.totalHits, docs.totalHits);
>     }
> 
> On Sun, Jun 19, 2011 at 12:43 PM, Ahmet Arslan <io...@yahoo.com> wrote:
> > > Beside creating an index with just the site in question, is
> > > it possible like
> > > with Google to search for results only in a given domain?
> > 
> > If you have an appropriate field that is indexed, yes. fq=site:foo.com
> > http://wiki.apache.org/solr/CommonQueryParameters#fq