Complex and/or queries on Q search endpoint

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Complex and/or queries on Q search endpoint

César Martínez Izquierdo-3
Hi, I am trying to perform complex queries on the Q search endpoint,
following the documentation available on [1], but I am getting some
unexpected results.

If I try to do a query like this one (using pseudo-code syntax):

(title=DEM* AND title=v2020*)

Then I can use the following syntax:
/geonetwork/srv/eng/q?_content_type=json&title=DEM*&title=v2020*&from=1&to=50&bucket=s101&facet.q=&fast=index&resultType=details&sortBy=relevance

This works as expected. However, if I try to do a query like this one
(title=DEM* OR abstract=DEM*) AND (title=v2020* OR abstract=v2020*)

I would expect that I could produce the query using the following
search parameters:

/geonetwork/srv/eng/q?_content_type=json&title_OR_abstract=DEM*&title_OR_abstract=v2020*&from=1&to=50&bucket=s101&facet.q=&fast=index&resultType=details&sortBy=relevance

Unfortunately this produces more results than expected. I would say it
is actually translated to a query such as:
(title=DEM* OR abstract=DEM* OR title=v2020* OR abstract=v2020*)

I would even be able to perform searches such as:
(title=DEM* OR abstract=DEM* OR title=DTM* OR abstract=DTM*) AND
(title=v2020* OR abstract=v2020*)

Again, according to documentation, I would expect I could use:
/geonetwork/srv/eng/q?_content_type=json&title_OR_abstract=DEM* or
DTM*&title_OR_abstract=v2020*&from=1&to=50&bucket=s101&facet.q=&fast=index&resultType=details&sortBy=relevance

However, this produces again a search such as
(title=DEM* OR abstract=DEM* OR title=DTM* OR abstract=DTM* OR
title=v2020* OR abstract=v2020*)

Is this a bug or is this an expected result? Is there any way to
perform that kind of queries in the Q interface?

Thanks,

César Martínez

[1] https://geonetwork-opensource.org/manuals/trunk/eng/users/api/q-search.html

--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   César Martínez Izquierdo
   GIS developer
   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
   SCOLAB: http://www.scolab.es
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


_______________________________________________
GeoNetwork-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geonetwork-users
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork
Reply | Threaded
Open this post in threaded view
|

Re: Complex and/or queries on Q search endpoint

Francois Prunayre
Hi,

Le mar. 18 févr. 2020 à 19:09, César Martínez Izquierdo <[hidden email]>
a écrit :

> Hi, I am trying to perform complex queries on the Q search endpoint,
> following the documentation available on [1], but I am getting some
> unexpected results.
>
> If I try to do a query like this one (using pseudo-code syntax):
>
> (title=DEM* AND title=v2020*)
>
> Then I can use the following syntax:
>
> /geonetwork/srv/eng/q?_content_type=json&title=DEM*&title=v2020*&from=1&to=50&bucket=s101&facet.q=&fast=index&resultType=details&sortBy=relevance
>
> This works as expected. However, if I try to do a query like this one
> (title=DEM* OR abstract=DEM*) AND (title=v2020* OR abstract=v2020*)
>

Lucene index is not a database. All fields are flattened and there is no
link between title and abstract between documents.
Same will occur if you want to query a contact with specific role. You need
to index the joined info and then query that field eg.
https://github.com/geonetwork/core-geonetwork/blob/master/schemas/iso19139/src/main/plugin/iso19139/index-fields/default.xsl#L1087
If you want to achieve that, you need to create a field combining title and
abstract.

Cheers.

Francois



>
> I would expect that I could produce the query using the following
> search parameters:
>
>
> /geonetwork/srv/eng/q?_content_type=json&title_OR_abstract=DEM*&title_OR_abstract=v2020*&from=1&to=50&bucket=s101&facet.q=&fast=index&resultType=details&sortBy=relevance
>
> Unfortunately this produces more results than expected. I would say it
> is actually translated to a query such as:
> (title=DEM* OR abstract=DEM* OR title=v2020* OR abstract=v2020*)
>
> I would even be able to perform searches such as:
> (title=DEM* OR abstract=DEM* OR title=DTM* OR abstract=DTM*) AND
> (title=v2020* OR abstract=v2020*)
>
> Again, according to documentation, I would expect I could use:
> /geonetwork/srv/eng/q?_content_type=json&title_OR_abstract=DEM* or
>
> DTM*&title_OR_abstract=v2020*&from=1&to=50&bucket=s101&facet.q=&fast=index&resultType=details&sortBy=relevance
>
> However, this produces again a search such as
> (title=DEM* OR abstract=DEM* OR title=DTM* OR abstract=DTM* OR
> title=v2020* OR abstract=v2020*)
>
> Is this a bug or is this an expected result? Is there any way to
> perform that kind of queries in the Q interface?
>
> Thanks,
>
> César Martínez
>
> [1]
> https://geonetwork-opensource.org/manuals/trunk/eng/users/api/q-search.html
>
> --
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>    César Martínez Izquierdo
>    GIS developer
>    -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
>    SCOLAB: http://www.scolab.es
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>
>
> _______________________________________________
> GeoNetwork-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/geonetwork-users
> GeoNetwork OpenSource is maintained at
> http://sourceforge.net/projects/geonetwork
>

_______________________________________________
GeoNetwork-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geonetwork-users
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork
Reply | Threaded
Open this post in threaded view
|

Re: Complex and/or queries on Q search endpoint

César Martínez Izquierdo-3
Hi Francois, your answer confuses me, because the title_OR_abstract
syntax works correctly in Geonetwork, so probably both fields already
exist in the index and are queried. My problem is that I want to
combine ORs and ANDs and I was expecting that I would get an AND query
if I repeat the parameter, because that is the documented behaviour
when repeating clauses:
topicCat=biota&topicCat=farming

I will anyway look at your suggestion of creating a new field.
Thanks

César

On Thu, 20 Feb 2020 at 17:44, Francois Prunayre <[hidden email]> wrote:

>
> Hi,
>
> Le mar. 18 févr. 2020 à 19:09, César Martínez Izquierdo <[hidden email]> a écrit :
>>
>> Hi, I am trying to perform complex queries on the Q search endpoint,
>> following the documentation available on [1], but I am getting some
>> unexpected results.
>>
>> If I try to do a query like this one (using pseudo-code syntax):
>>
>> (title=DEM* AND title=v2020*)
>>
>> Then I can use the following syntax:
>> /geonetwork/srv/eng/q?_content_type=json&title=DEM*&title=v2020*&from=1&to=50&bucket=s101&facet.q=&fast=index&resultType=details&sortBy=relevance
>>
>> This works as expected. However, if I try to do a query like this one
>> (title=DEM* OR abstract=DEM*) AND (title=v2020* OR abstract=v2020*)
>
>
> Lucene index is not a database. All fields are flattened and there is no link between title and abstract between documents.
> Same will occur if you want to query a contact with specific role. You need to index the joined info and then query that field eg. https://github.com/geonetwork/core-geonetwork/blob/master/schemas/iso19139/src/main/plugin/iso19139/index-fields/default.xsl#L1087
> If you want to achieve that, you need to create a field combining title and abstract.
>
> Cheers.
>
> Francois
>
>
>>
>>
>> I would expect that I could produce the query using the following
>> search parameters:
>>
>> /geonetwork/srv/eng/q?_content_type=json&title_OR_abstract=DEM*&title_OR_abstract=v2020*&from=1&to=50&bucket=s101&facet.q=&fast=index&resultType=details&sortBy=relevance
>>
>> Unfortunately this produces more results than expected. I would say it
>> is actually translated to a query such as:
>> (title=DEM* OR abstract=DEM* OR title=v2020* OR abstract=v2020*)
>>
>> I would even be able to perform searches such as:
>> (title=DEM* OR abstract=DEM* OR title=DTM* OR abstract=DTM*) AND
>> (title=v2020* OR abstract=v2020*)
>>
>> Again, according to documentation, I would expect I could use:
>> /geonetwork/srv/eng/q?_content_type=json&title_OR_abstract=DEM* or
>> DTM*&title_OR_abstract=v2020*&from=1&to=50&bucket=s101&facet.q=&fast=index&resultType=details&sortBy=relevance
>>
>> However, this produces again a search such as
>> (title=DEM* OR abstract=DEM* OR title=DTM* OR abstract=DTM* OR
>> title=v2020* OR abstract=v2020*)
>>
>> Is this a bug or is this an expected result? Is there any way to
>> perform that kind of queries in the Q interface?
>>
>> Thanks,
>>
>> César Martínez
>>
>> [1] https://geonetwork-opensource.org/manuals/trunk/eng/users/api/q-search.html
>>
>> --
>> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>    César Martínez Izquierdo
>>    GIS developer
>>    -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
>>    SCOLAB: http://www.scolab.es
>> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>
>>
>> _______________________________________________
>> GeoNetwork-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/geonetwork-users
>> GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork



--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   César Martínez Izquierdo
   GIS developer
   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
   SCOLAB: http://www.scolab.es
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


_______________________________________________
GeoNetwork-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geonetwork-users
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork