You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Rafael Troilo <ra...@uni-heidelberg.de> on 2016/12/14 18:13:21 UTC

Index wont't be used with QueryEntity configuration

Hi,

I just try out the SpatialQueryExample and don't want to us annotations 
for the MapPoint class, but I have trouble to get the index to work.

Here is what I see:

CacheConfiguration<Integer, MapPoint> cc = new 
CacheConfiguration<>(CACHE_NAME);

SQL:  "explain analyze select _val from MapPoint where coords && ?"

With Annotiations:

cc.setIndexedTypes(Integer.class,MapPoint.class);

I got:

[[SELECT
     _VAL AS __C0
FROM "SpatialQueryExample".MAPPOINT
     /* "SpatialQueryExample"."coords_idx": COORDS && ?1 */
WHERE INTERSECTS(COORDS, ?1)], [SELECT
     __C0 AS _VAL
FROM PUBLIC.__T0
     /* "SpatialQueryExample"."merge_scan" */]]


With QueryEntity:

QueryEntity queryEntity = new QueryEntity(Integer.class.getName(), 
MapPoint.class.getName());
LinkedHashMap<String, String> fields = new LinkedHashMap<>();
fields.put("coords", Geometry.class.getName());
queryEntity.setFields(fields);
queryEntity.setIndexes(Arrays.asList(new QueryIndex("coords")));
cc.setQueryEntities(Arrays.asList(queryEntity));

I got:

[[SELECT
     _VAL AS __C0
FROM "SpatialQueryExample".MAPPOINT
     /* "SpatialQueryExample".MAPPOINT.__SCAN_ */
WHERE INTERSECTS(COORDS, ?1)], [SELECT
     __C0 AS _VAL
FROM PUBLIC.__T0
     /* "SpatialQueryExample"."merge_scan" */]]


The index won't be used in the QueryEntity configuration.

Do I do something wrong? Or do you have any suggestions?

Thank you!

Ciao,

Rafael

-- 
Rafael Troilo, Dipl.-Inform. (FH)
    GIScience Research Group
   
    Heidelberg Institute for Geoinformation Technology

    rafael.troilo@uni-heidelberg.de
    http://giscience.uni-hd.de
    http://www.geog.uni-heidelberg.de/gis/heigit.html
   
    Berliner Str. 45 (Mathematikon), D-69120 Heidelberg, Germany
    fon: +49(0)6221 / 54 / 19704


Re: Index wont't be used with QueryEntity configuration

Posted by Rafael Troilo <ra...@uni-heidelberg.de>.
Hello Val,

great answer! thank you!

Ciao,

Rafael



On 14.12.2016 20:41, vkulichenko wrote:
> When configuring with QueryEntity, Ignite doesn't now the exact field type,
> so it creates a regular sorted index by default. You need to specify that
> this is a geospatial index explicitly:
>
> new QueryIndex("coords", QueryIndexType.GEOSPATIAL)
>
> -Val
>
>
>
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Index-wont-t-be-used-with-QueryEntity-configuration-tp9538p9545.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.

-- 
Rafael Troilo, Dipl.-Inform. (FH)
    GIScience Research Group
   
    Heidelberg Institute for Geoinformation Technology

    rafael.troilo@uni-heidelberg.de
    http://giscience.uni-hd.de
    http://www.geog.uni-heidelberg.de/gis/heigit.html
   
    Berliner Str. 45 (Mathematikon), D-69120 Heidelberg, Germany
    fon: +49(0)6221 / 54 / 19704


Re: Index wont't be used with QueryEntity configuration

Posted by vkulichenko <va...@gmail.com>.
When configuring with QueryEntity, Ignite doesn't now the exact field type,
so it creates a regular sorted index by default. You need to specify that
this is a geospatial index explicitly:

new QueryIndex("coords", QueryIndexType.GEOSPATIAL)

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Index-wont-t-be-used-with-QueryEntity-configuration-tp9538p9545.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.