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 Olivier Ricordeau <ol...@ricordeau.org> on 2010/07/19 12:35:23 UTC
Spatial filtering
Hi folks,
I can't manage to have the new spatial filtering feature (added in
r962727 by Grant Ingersoll, see
https://issues.apache.org/jira/browse/SOLR-1568) working. I'm trying to
get all the documents located within a circle defined by its center and
radius.
I've modified my query url as specified in
http://wiki.apache.org/solr/SpatialSearch#Spatial_Filter_QParser to add
the "pt", "d" and "meas" parameters. Here is what my query parameters
looks like (from Solr's response with debug mode activated):
[params] => Array
(
[explainOther] => true
[mm] => 2<-75%
[d] => 50
[sort] => date asc
[qf] =>
[wt] => php
[rows] => 5000
[version] => 2.2
[fl] => object_type object_id score
[debugQuery] => true
[start] => 0
[q] => *:*
[meas] => hsin
[pt] => 48.85341,2.3488
[bf] =>
[qt] => standard
[fq] => +object_type:Concert
+date:[2010-07-19T00:00:00Z TO 2011-07-19T23:59:59Z]
)
With this query, I get 3859 results. And some (lots) of the found
documents are not located whithin the circle! :(
If I run the same query without spatial filtering (if I remove the "pt",
"d" and "meas" parameters from the url), I get 3859 results too. So it
looks like my spatial filtering constraint is not taken into account in
the first search query (the one where "pt", "d" and "meas" are set). Is
the wiki's doc up to date?
In the comments of SOLR-1568, I've seen someone talking about adding
"{!sfilt fl=latlon_field_name}". So I tried the following request:
[params] => Array
(
[explainOther] => true
[mm] => 2<-75%
[d] => 50
[sort] => date asc
[qf] =>
[wt] => php
[rows] => 5000
[version] => 2.2
[fl] => object_type object_id score
[debugQuery] => true
[start] => 0
[q] => *:*
[meas] => hsin
[pt] => 48.85341,2.3488
[bf] =>
[qt] => standard
[fq] => +object_type:Concert
+date:[2010-07-19T00:00:00Z TO 2011-07-19T23:59:59Z] +{!sfilt
fl=coords_lat_lon,units=km,meas=hsin}
)
This leads to 2713 results (which is smaller than 3859, good). But some
(lots) of the results are once more out of the circle :(
Can someone help me get spatial filtering working? I really don't
understand the search results I'm getting.
Cheers,
Olivier
--
- *Olivier RICORDEAU* -
olivier@ricordeau.org
http://olivier.ricordeau.org
Re: Spatial filtering
Posted by Olivier Ricordeau <ol...@ricordeau.org>.
Ok, I have found a big bug in my indexing script. Things are getting
better. I managed to have my parsed_filter_query to:
+coords_lat_lon_0_latLon:[48.694179707855874 TO 49.01213545059667]
+coords_lat_lon_1_latLon:[2.1079512793239767 TO 2.5911832073858765]
For the record, here are the parameters which made it work:
[params] => Array
(
[explainOther] => true
[mm] => 2<-75%
[d] => 25
[sort] => date asc
[qf] =>
[wt] => php
[rows] => 5000
[version] => 2.2
[fl] => * score
[debugQuery] => true
[start] => 0
[q] => *:*
[meas] => hsin
[pt] => 48.85341,2.3488
[bf] =>
[qt] => standard
[fq] => {!sfilt fl=coords_lat_lon}
+object_type:Concert +date:[2008-07-20T00:00:00Z TO 2011-07-20T23:59:59Z]
)
But I am facing one problem: the " +object_type:Concert +
date:[2008-07-20T00:00:00Z TO 2011-07-20T23:59:59Z]" part of my fq
parameter is not taken into account (see the parsed_filter_query above).
So here is my question:
How can I mix the "{!sfilt fl=coords_lat_lon}" part of the fq parameter
with "usual" fq parameters (eg: "+object_type:Concert")?
Can anyone help?
Regards,
Olivier
Le 20/07/2010 09:53, Olivier Ricordeau a écrit :
>
>
> Le 20/07/2010 04:18, Lance Norskog a écrit :
>> Add the debugQuery=true parameter and it will show you the Lucene
>> query tree, and how each document is evaluated. This can help with the
>> more complex queries.
>
> Do you see something wrong?
>
> [debug] => Array
> (
> [rawquerystring] => *:*
> [querystring] => *:*
> [parsedquery] => MatchAllDocsQuery(*:*)
> [parsedquery_toString] => *:*
> [explain] => Array
> (
> [doc_45269] =>
> 1.0 = (MATCH) MatchAllDocsQuery, product of:
> 1.0 = queryNorm
>
> [doc_50206] =>
> 1.0 = (MATCH) MatchAllDocsQuery, product of:
> 1.0 = queryNorm
>
> [doc_50396] =>
> 1.0 = (MATCH) MatchAllDocsQuery, product of:
> 1.0 = queryNorm
>
> [doc_51199] =>
> 1.0 = (MATCH) MatchAllDocsQuery, product of:
> 1.0 = queryNorm
>
> [....]
>
> )
>
> [QParser] => LuceneQParser
> [filter_queries] => Array
> (
> [0] => +object_type:Concert +date:[2010-07-20T00:00:00Z TO
> 2011-07-20T23:59:59Z] +{!sfilt fl=coords_lat_lon,units=km,meas=hsin}
> )
>
> [parsed_filter_queries] => Array
> (
> [0] => +object_type:Concert +date:[1279584000000 TO 1311206399000]
> +name:{!sfilt TO fl=coords_lat_lon,units=km,meas=hsin}
> )
>
> [...]
>
> I'm not sure about the "parsed_filter_queries" entry. It looks like the
> "+{!sfilt fl=coords_lat_lon,units=km,meas=hsin}" is not well interpreted
> (seems like it's interpreted as a range). Does anyone know what the
> right syntax? This is not documented...
>
> Cheers,
> Olivier
>
>>
>> On Mon, Jul 19, 2010 at 3:35 AM, Olivier Ricordeau
>> <ol...@ricordeau.org> wrote:
>>> Hi folks,
>>>
>>> I can't manage to have the new spatial filtering feature (added in
>>> r962727
>>> by Grant Ingersoll, see https://issues.apache.org/jira/browse/SOLR-1568)
>>> working. I'm trying to get all the documents located within a circle
>>> defined
>>> by its center and radius.
>>> I've modified my query url as specified in
>>> http://wiki.apache.org/solr/SpatialSearch#Spatial_Filter_QParser to
>>> add the
>>> "pt", "d" and "meas" parameters. Here is what my query parameters
>>> looks like
>>> (from Solr's response with debug mode activated):
>>>
>>> [params] => Array
>>> (
>>> [explainOther] => true
>>> [mm] => 2<-75%
>>> [d] => 50
>>> [sort] => date asc
>>> [qf] =>
>>> [wt] => php
>>> [rows] => 5000
>>> [version] => 2.2
>>> [fl] => object_type object_id score
>>> [debugQuery] => true
>>> [start] => 0
>>> [q] => *:*
>>> [meas] => hsin
>>> [pt] => 48.85341,2.3488
>>> [bf] =>
>>> [qt] => standard
>>> [fq] => +object_type:Concert +date:[2010-07-19T00:00:00Z
>>> TO 2011-07-19T23:59:59Z]
>>> )
>>>
>>>
>>>
>>> With this query, I get 3859 results. And some (lots) of the found
>>> documents
>>> are not located whithin the circle! :(
>>> If I run the same query without spatial filtering (if I remove the
>>> "pt", "d"
>>> and "meas" parameters from the url), I get 3859 results too. So it looks
>>> like my spatial filtering constraint is not taken into account in the
>>> first
>>> search query (the one where "pt", "d" and "meas" are set). Is the
>>> wiki's doc
>>> up to date?
>>>
>>> In the comments of SOLR-1568, I've seen someone talking about adding
>>> "{!sfilt fl=latlon_field_name}". So I tried the following request:
>>>
>>> [params] => Array
>>> (
>>> [explainOther] => true
>>> [mm] => 2<-75%
>>> [d] => 50
>>> [sort] => date asc
>>> [qf] =>
>>> [wt] => php
>>> [rows] => 5000
>>> [version] => 2.2
>>> [fl] => object_type object_id score
>>> [debugQuery] => true
>>> [start] => 0
>>> [q] => *:*
>>> [meas] => hsin
>>> [pt] => 48.85341,2.3488
>>> [bf] =>
>>> [qt] => standard
>>> [fq] => +object_type:Concert +date:[2010-07-19T00:00:00Z
>>> TO 2011-07-19T23:59:59Z] +{!sfilt fl=coords_lat_lon,units=km,meas=hsin}
>>> )
>>>
>>> This leads to 2713 results (which is smaller than 3859, good). But some
>>> (lots) of the results are once more out of the circle :(
>>>
>>> Can someone help me get spatial filtering working? I really don't
>>> understand
>>> the search results I'm getting.
>>>
>>> Cheers,
>>> Olivier
>>>
>>> --
>>> - *Olivier RICORDEAU* -
>>> olivier@ricordeau.org
>>> http://olivier.ricordeau.org
>>>
>>>
>>
>>
>>
>
--
- *Olivier RICORDEAU* -
olivier@ricordeau.org
http://olivier.ricordeau.org
Re: Spatial filtering
Posted by Olivier Ricordeau <ol...@ricordeau.org>.
Le 20/07/2010 04:18, Lance Norskog a écrit :
> Add the debugQuery=true parameter and it will show you the Lucene
> query tree, and how each document is evaluated. This can help with the
> more complex queries.
Do you see something wrong?
[debug] => Array
(
[rawquerystring] => *:*
[querystring] => *:*
[parsedquery] => MatchAllDocsQuery(*:*)
[parsedquery_toString] => *:*
[explain] => Array
(
[doc_45269] =>
1.0 = (MATCH) MatchAllDocsQuery, product of:
1.0 = queryNorm
[doc_50206] =>
1.0 = (MATCH) MatchAllDocsQuery, product of:
1.0 = queryNorm
[doc_50396] =>
1.0 = (MATCH) MatchAllDocsQuery, product of:
1.0 = queryNorm
[doc_51199] =>
1.0 = (MATCH) MatchAllDocsQuery, product of:
1.0 = queryNorm
[....]
)
[QParser] => LuceneQParser
[filter_queries] => Array
(
[0] => +object_type:Concert
+date:[2010-07-20T00:00:00Z TO 2011-07-20T23:59:59Z] +{!sfilt
fl=coords_lat_lon,units=km,meas=hsin}
)
[parsed_filter_queries] => Array
(
[0] => +object_type:Concert +date:[1279584000000 TO
1311206399000] +name:{!sfilt TO fl=coords_lat_lon,units=km,meas=hsin}
)
[...]
I'm not sure about the "parsed_filter_queries" entry. It looks like the
"+{!sfilt fl=coords_lat_lon,units=km,meas=hsin}" is not well interpreted
(seems like it's interpreted as a range). Does anyone know what the
right syntax? This is not documented...
Cheers,
Olivier
>
> On Mon, Jul 19, 2010 at 3:35 AM, Olivier Ricordeau
> <ol...@ricordeau.org> wrote:
>> Hi folks,
>>
>> I can't manage to have the new spatial filtering feature (added in r962727
>> by Grant Ingersoll, see https://issues.apache.org/jira/browse/SOLR-1568)
>> working. I'm trying to get all the documents located within a circle defined
>> by its center and radius.
>> I've modified my query url as specified in
>> http://wiki.apache.org/solr/SpatialSearch#Spatial_Filter_QParser to add the
>> "pt", "d" and "meas" parameters. Here is what my query parameters looks like
>> (from Solr's response with debug mode activated):
>>
>> [params] => Array
>> (
>> [explainOther] => true
>> [mm] => 2<-75%
>> [d] => 50
>> [sort] => date asc
>> [qf] =>
>> [wt] => php
>> [rows] => 5000
>> [version] => 2.2
>> [fl] => object_type object_id score
>> [debugQuery] => true
>> [start] => 0
>> [q] => *:*
>> [meas] => hsin
>> [pt] => 48.85341,2.3488
>> [bf] =>
>> [qt] => standard
>> [fq] => +object_type:Concert +date:[2010-07-19T00:00:00Z
>> TO 2011-07-19T23:59:59Z]
>> )
>>
>>
>>
>> With this query, I get 3859 results. And some (lots) of the found documents
>> are not located whithin the circle! :(
>> If I run the same query without spatial filtering (if I remove the "pt", "d"
>> and "meas" parameters from the url), I get 3859 results too. So it looks
>> like my spatial filtering constraint is not taken into account in the first
>> search query (the one where "pt", "d" and "meas" are set). Is the wiki's doc
>> up to date?
>>
>> In the comments of SOLR-1568, I've seen someone talking about adding
>> "{!sfilt fl=latlon_field_name}". So I tried the following request:
>>
>> [params] => Array
>> (
>> [explainOther] => true
>> [mm] => 2<-75%
>> [d] => 50
>> [sort] => date asc
>> [qf] =>
>> [wt] => php
>> [rows] => 5000
>> [version] => 2.2
>> [fl] => object_type object_id score
>> [debugQuery] => true
>> [start] => 0
>> [q] => *:*
>> [meas] => hsin
>> [pt] => 48.85341,2.3488
>> [bf] =>
>> [qt] => standard
>> [fq] => +object_type:Concert +date:[2010-07-19T00:00:00Z
>> TO 2011-07-19T23:59:59Z] +{!sfilt fl=coords_lat_lon,units=km,meas=hsin}
>> )
>>
>> This leads to 2713 results (which is smaller than 3859, good). But some
>> (lots) of the results are once more out of the circle :(
>>
>> Can someone help me get spatial filtering working? I really don't understand
>> the search results I'm getting.
>>
>> Cheers,
>> Olivier
>>
>> --
>> - *Olivier RICORDEAU* -
>> olivier@ricordeau.org
>> http://olivier.ricordeau.org
>>
>>
>
>
>
--
- *Olivier RICORDEAU* -
olivier@ricordeau.org
http://olivier.ricordeau.org
Re: Spatial filtering
Posted by Lance Norskog <go...@gmail.com>.
Add the debugQuery=true parameter and it will show you the Lucene
query tree, and how each document is evaluated. This can help with the
more complex queries.
On Mon, Jul 19, 2010 at 3:35 AM, Olivier Ricordeau
<ol...@ricordeau.org> wrote:
> Hi folks,
>
> I can't manage to have the new spatial filtering feature (added in r962727
> by Grant Ingersoll, see https://issues.apache.org/jira/browse/SOLR-1568)
> working. I'm trying to get all the documents located within a circle defined
> by its center and radius.
> I've modified my query url as specified in
> http://wiki.apache.org/solr/SpatialSearch#Spatial_Filter_QParser to add the
> "pt", "d" and "meas" parameters. Here is what my query parameters looks like
> (from Solr's response with debug mode activated):
>
> [params] => Array
> (
> [explainOther] => true
> [mm] => 2<-75%
> [d] => 50
> [sort] => date asc
> [qf] =>
> [wt] => php
> [rows] => 5000
> [version] => 2.2
> [fl] => object_type object_id score
> [debugQuery] => true
> [start] => 0
> [q] => *:*
> [meas] => hsin
> [pt] => 48.85341,2.3488
> [bf] =>
> [qt] => standard
> [fq] => +object_type:Concert +date:[2010-07-19T00:00:00Z
> TO 2011-07-19T23:59:59Z]
> )
>
>
>
> With this query, I get 3859 results. And some (lots) of the found documents
> are not located whithin the circle! :(
> If I run the same query without spatial filtering (if I remove the "pt", "d"
> and "meas" parameters from the url), I get 3859 results too. So it looks
> like my spatial filtering constraint is not taken into account in the first
> search query (the one where "pt", "d" and "meas" are set). Is the wiki's doc
> up to date?
>
> In the comments of SOLR-1568, I've seen someone talking about adding
> "{!sfilt fl=latlon_field_name}". So I tried the following request:
>
> [params] => Array
> (
> [explainOther] => true
> [mm] => 2<-75%
> [d] => 50
> [sort] => date asc
> [qf] =>
> [wt] => php
> [rows] => 5000
> [version] => 2.2
> [fl] => object_type object_id score
> [debugQuery] => true
> [start] => 0
> [q] => *:*
> [meas] => hsin
> [pt] => 48.85341,2.3488
> [bf] =>
> [qt] => standard
> [fq] => +object_type:Concert +date:[2010-07-19T00:00:00Z
> TO 2011-07-19T23:59:59Z] +{!sfilt fl=coords_lat_lon,units=km,meas=hsin}
> )
>
> This leads to 2713 results (which is smaller than 3859, good). But some
> (lots) of the results are once more out of the circle :(
>
> Can someone help me get spatial filtering working? I really don't understand
> the search results I'm getting.
>
> Cheers,
> Olivier
>
> --
> - *Olivier RICORDEAU* -
> olivier@ricordeau.org
> http://olivier.ricordeau.org
>
>
--
Lance Norskog
goksron@gmail.com