I think it would not be difficult to set Jena for text and spatial, by adding the indexes in the so-called Context (org.apache.jena.sparql.util .Context) of the DatasetGraph . But achieving dynamic update of both indexes when TDB is updated will require extending the implementation along the line of preceding mail.
I wonder if new GeoSPARQL implementation will be compatible with textual indexing . Le dim. 23 déc. 2018 à 11:53, Jean-Marc Vanel <[email protected]> a écrit : > Thanks Bruno for sharing your trials; alas you're not further than I. > Using gist.github.com is indeed better than the regular git, like I do, > for sharing trials. > > I'm getting skeptical about doing spatial + textual as the Jena API > stands. > For one thing, nobody stood up and said "I did it" since 10 days. > Second, spatial and textual indexing follow a similar design, but not > readily mixable: > > - TextDatasetFactory 's create() method returns a DatasetGraphText > - SpatialDatasetFactory create() method returns a DatasetGraphSpatial > > Both classes DatasetGraphText and DatasetGraphSpatial have their > respective index as members and extend DatasetGraphMonitor so that they get > notified of add or delete to the DatasetGraph. > Moreover, alas, the DatasetGraphMonitor class does not follow the observer > design pattern <https://en.wikipedia.org/wiki/Observer_pattern> , which > would allow to attach several observer objects to the same DatasetGraph. > The monitor in DatasetGraphMonitor class is interface DatasetChanges. > > So the solution I can think of at the moment is creating a mixin > class DatasetGraphTextSpatial with delegation like this: > > class DatasetGraphTextSpatial extends DatasetGraphWrapper { > DatasetGraphText datasetGraphText; > DatasetGraphSpatial datasetGraphSpatial; > public DatasetGraphTextSpatial(DatasetGraph dsg) { > super(dsg); > } > // delegating all methods to both members: > public void commit() { > datasetGraphText.commit(); > datasetGraphSpatial.commit(); > } > // etc (tedious) ... > } > > > Le dim. 23 déc. 2018 à 09:13, Bruno P. Kinoshita <[email protected]> a > écrit : > >> Hi, >> >> I had a crack at it, without luck. Here's my set up: >> https://gist.github.com/kinow/f391be7036b63f8ac0c08b9832e8bfa7 >> >> I started with a Spatial only, using a configuration turtle file from >> Jena Spatial tests (see gist's spatial1.ttl). Loaded the dataset (also from >> tests), a query with spatial:nearby worked (geoarq-data-1.ttl & >> geoarq-data-1-query.ttl in the gist above). >> >> Then started by modifying the spatial Lucene Index, adding the properties >> necessary for a Jena Text dataset (see gist's spatial-text.ttl). Tried to >> make both, the spatial lucene index and the text lucene index point to the >> same directory. >> >> >> Once I started Fuseki (see comments in gist for rest of set up), the >> spatial query was still working, but even though I had a text:index >> pointing to an index, when the query was executed, it would be delegated to >> the DatasetGraphSpatial. This dataset knows nothing of text, and when the >> TextQueryPF is executed, the textIndex is null. My logs have: >> >> [2018-12-23 21:03:57] TextQueryPF WARN Failed to find the text index : >> tried context and as a text-enabled dataset >> [2018-12-23 21:03:57] TextQueryPF WARN No text index - no text search >> performed >> >> So alas I couldn't post a working example. >> >> Hope that helps anyway >> >> Bruno >> >> ps: Lucene locks its indexes, so I **guess** if you tried a different >> approach of having another Fuseki pointing to the same directory, it would >> probably raise an exception at some point >> >> >> ________________________________ >> >> From: Jean-Marc Vanel <[email protected]> >> To: Jena users <[email protected]> >> Sent: Saturday, 22 December 2018 10:03 PM >> Subject: Re: Build by program a Dataset that is both textual and spatial >> >> >> >> I reverted to trying configuration by code, with 2 more tries: >> >> https://github.com/jmvanel/semantic_forms/blob/master/scala/forms/src/main/scala/deductions/runtime/jena/lucene/LuceneIndex.scala#L109 >> : >> add to textual Dataset's Context a spatialIndex key to the spatialIndex. >> >> and line 135 : >> Use same Lucene directory for both indexes (not forgetting to spatially >> index the existing textual index). >> WARN >> org.apache.jena.query.spatial.pfunction.SpatialOperationWithCircleBase >> - Failed to find the spatial index : tried context and as a >> spatial-enabled dataset >> >> Both fail! >> >> My best hope is to look into Fuseki code, >> but can someone confirm that Fuseki does spatial WITH textual Indexing? >> >> I already looked into Fuseki code, but could not find calls to spatial or >> textual factory in jena-fuseki1/src/main/java/org/apache/jena/fuseki/ . >> >> >> Le ven. 21 déc. 2018 à 11:29, Jean-Marc Vanel <[email protected]> >> a >> écrit : >> >> > I'm still clueless about how to configure Jena for textual AND spatial >> > indexes. >> > I tried yet another assembler file: >> > >> > >> https://github.com/jmvanel/semantic_forms/blob/master/scala/jena.spatial%2Btext3.assembler.ttl >> > but even less good as >> > >> > >> https://github.com/jmvanel/semantic_forms/blob/master/scala/jena.spatial%2Btext2.assembler.ttl >> > reported just before. >> > >> > It seems that nobody uses both indexes by program; >> > otherwise I'd like to know how you do; you can send me privately your >> > assembler files. >> > >> > Fuseki claims to "incorporate Jena text query >> > <https://jena.apache.org/documentation/query/text-query.html> and Jena >> > spatial query >> > <https://jena.apache.org/documentation/query/spatial-query.html>" in >> this >> > documentation: >> > https://jena.apache.org/documentation/fuseki2/ >> > So there is a way to configure Jena for textual AND spatial indexes! >> > In absence of other help, I'll have to look into Fuseki code. >> > >> > NOTE: the error message "*tried context and as a text-enabled dataset*" >> > maybe hints at a solution, but the word "context" is not clear. >> > >> > >> > >> > >> > >> > Le lun. 17 déc. 2018 à 14:51, Jean-Marc Vanel <[email protected] >> > >> > a écrit : >> > >> >> >> >> >> >> Le lun. 17 déc. 2018 à 13:24, Andy Seaborne <[email protected]> a écrit >> : >> >> >> >>> ... >> >>> :spatial_dataset rdf:type spatial:SpatialDataset ; >> >>> rdf:type text:TextDataset ; >> >>> ... >> >>> >> >>> Not sure but I think the system will create this twice. >> >>> >> >>> It would be better to have two declarations, one for spatial, one for >> >>> text. I'm not sure what happen if they share the same :directory - it >> >>> might work, it might not. >> >>> >> >> >> >> So, if one want to make queries that are both textual and spatial, >> >> having two declarations, one for spatial, one for text, sharing the >> same >> >> directory, appears as the only solution . >> >> I tested and report here. >> >> The current assembler file: >> >> >> >> >> https://github.com/jmvanel/semantic_forms/blob/master/scala/jena.spatial%2Btext2.assembler.ttl >> >> Results: >> >> >> >> - spatial query works, textual query has empty result, but no >> >> message in log, when *calling with spatial Dataset* in call >> >> to DatasetFactory.assemble() >> >> - spatial query works, textual query has result independant of the >> >> string searched, and messages in log "Failed to find the text >> index" , "No >> >> text index - no text search performed : tried context and as a >> text-enabled >> >> dataset", when *calling with textual Dataset *in call to >> >> DatasetFactory.assemble() >> >> >> >> The query tested for text: >> >> PREFIX text: <http://jena.apache.org/text#> >> >> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> >> >> SELECT * >> >> WHERE { >> >> ?s a <http://dbpedia.org/ontology/Garden> ; >> >> text:query (rdfs:label 'Gardens' ) ; >> >> } LIMIT 11 >> >> >> >> The spatial query tested: >> >> >> >> PREFIX spatial: <http://jena.apache.org/spatial#> >> >> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> >> >> SELECT DISTINCT ?placeName ?place >> >> WHERE { >> >> ?place spatial:nearby ( >> >> 45.750000 4.85 # Lyon >> >> 1000 'km') . >> >> ?place rdfs:label ?placeName >> >> FILTER( LANG( ?placeName) = 'en' ) >> >> } LIMIT 111 >> >> >> >> Data: the 2600 dboGarden in dbPedia endpoint. >> >> >> >> >> >> >> >>> Andy >> >>> >> >>> On 16/12/2018 16:41, Jean-Marc Vanel wrote: >> >>> > Sorry , I sent a bad link on the list, my assembler file is really >> >>> this: >> >>> > >> >>> >> https://github.com/jmvanel/semantic_forms/blob/master/scala/jena.spatial%2Btext.assembler.ttl >> >>> > >> >>> > >> >>> > >> >>> > >> >>> > Le dim. 16 déc. 2018 à 13:40, Marco Neumann < >> [email protected]> >> >>> a >> >>> > écrit : >> >>> > >> >>> >> you are missing the text index in the assembler. >> >>> >> >> >>> >> On Sun, Dec 16, 2018 at 12:08 PM Jean-Marc Vanel < >> >>> [email protected] >> >>> >>> >> >>> >> wrote: >> >>> >> >> >>> >>> Yes indeed, >> >>> >>> exactly with this assembler file: >> >>> >>> >> >>> >>> >> >>> >> >> >>> >> https://github.com/jmvanel/semantic_forms/blob/master/scala/jena.spatial.assembler.ttl >> >>> >>> >> >>> >>> And, when the Jena based application is started with this same >> >>> assembler >> >>> >>> file, the spatial queries work , as said above in this thread. >> >>> >>> >> >>> >>> >> >>> >>> Le dim. 16 déc. 2018 à 12:18, Marco Neumann < >> [email protected]> >> >>> a >> >>> >>> écrit : >> >>> >>> >> >>> >>>> did you create the text index with jena.textindexer >> >>> >>>> --desc=/<path>/config.ttl? >> >>> >>>> >> >>> >>>> >> >>> >>>> On Sun, Dec 16, 2018 at 8:48 AM Jean-Marc Vanel < >> >>> >>> [email protected]> >> >>> >>>> wrote: >> >>> >>>> >> >>> >>>>> I fixed a stupid error in text index URI, resulting from >> pasting, >> >>> in >> >>> >>> new >> >>> >>>>> file jena.spatial+text.assembler.ttl: >> >>> >>>>> >> >>> >>>>> >> >>> >>>> >> >>> >>> >> >>> >> >> >>> >> https://github.com/jmvanel/semantic_forms/blob/master/scala/jena.spatial%2Btext.assembler.ttl >> >>> >>>>> >> >>> >>>>> Now, it reads: >> >>> >>>>> :spatial_dataset rdf:type spatial:SpatialDataset ; >> >>> >>>>> rdf:type text:TextDataset ; >> >>> >>>>> spatial:dataset <#dataset> ; >> >>> >>>>> spatial:index <#indexLucene> ; >> >>> >>>>> text:dataset <#dataset> ; >> >>> >>>>> text:index * <#indexLuceneText>* ; >> >>> >>>>> . >> >>> >>>>> >> >>> >>>>> But still it says "Failed to find the text index" . >> >>> >>>>> >> >>> >>>>> >> >>> >>>>> Le dim. 16 déc. 2018 à 09:34, Jean-Marc Vanel < >> >>> >>> [email protected]> >> >>> >>>> a >> >>> >>>>> écrit : >> >>> >>>>> >> >>> >>>>>> So I tried a new file jena.spatial+text.assembler.ttl with >> >>> >> separate >> >>> >>>>>> Lucene indices for spatial and text: >> >>> >>>>>> >> >>> >>>>>> >> >>> >>>>> >> >>> >>>> >> >>> >>> >> >>> >> >> >>> >> https://github.com/jmvanel/semantic_forms/blob/master/scala/jena.spatial%2Btext.assembler.ttl >> >>> >>>>>> >> >>> >>>>>> It defines a Dataset with both Dataset types and both Lucene >> >>> >> indices: >> >>> >>>>>> >> >>> >>>>>> :spatial_dataset rdf:type spatial:SpatialDataset ; >> >>> >>>>>> rdf:type text:TextDataset ; >> >>> >>>>>> spatial:dataset <#dataset> ; >> >>> >>>>>> spatial:index <#indexLucene> ; >> >>> >>>>>> text:dataset <#dataset> ; >> >>> >>>>>> text:index <#indexLucene> ; >> >>> >>>>>> . >> >>> >>>>>> >> >>> >>>>>> Alas , when querying , it says "Failed to find the text index" >> : >> >>> >>>>>> >> >>> >>>>>> WARN org.apache.jena.query.text.TextQueryPF - Failed to find >> the >> >>> >>> text >> >>> >>>>>> index : tried context and as a text-enabled dataset >> >>> >>>>>> WARN org.apache.jena.query.text.TextQueryPF - No text index - >> no >> >>> >>> text >> >>> >>>>>> search performed >> >>> >>>>>> >> >>> >>>>>> Is it because rdf:type spatial:SpatialDataset is asserted >> first in >> >>> >>>>>> assembler file? >> >>> >>>>>> So, defining a hybrid Dataset does not work anymore by TTL >> >>> >>>> specification >> >>> >>>>>> than by JVM code specification. >> >>> >>>>>> I definitely need more experts' advice . >> >>> >>>>>> >> >>> >>>>>> >> >>> >>>>>> >> >>> >>>>>> Le sam. 15 déc. 2018 à 21:10, ajs6f <[email protected]> a >> écrit : >> >>> >>>>>> >> >>> >>>>>>>> On Dec 15, 2018, at 9:59 AM, Marco Neumann < >> >>> >>> [email protected] >> >>> >>>>> >> >>> >>>>>>> wrote: >> >>> >>>>>>>> >> >>> >>>>>>>>> *Question*: does that make sense to have a unique Lucene >> index >> >>> >>> for >> >>> >>>>>>> text and >> >>> >>>>>>>>> space ? >> >>> >>>>>>>>> It is possible at all? If yes, is it good in terms of disk >> >>> >> space >> >>> >>>> and >> >>> >>>>>>>>> performance? >> >>> >>>>>>>>> Like this: >> >>> >>>>>>>>> <#indexLucene> a text:TextIndexLucene ; >> >>> >>>>>>>>> a spatial:SpatialIndexLucene ; >> >>> >>>>>>>>> # etc ... >> >>> >>>>>>> >> >>> >>>>>>> I'm sure that would be ideal for many cases, but I'm not at >> all >> >>> >> sure >> >>> >>>>> that >> >>> >>>>>>> the same index can answer queries of both kinds. Perhaps we >> can >> >>> >>>> combine >> >>> >>>>>>> fields from both, but are the relationships between tuple and >> >>> >> index >> >>> >>>>> record >> >>> >>>>>>> the same in both cases? >> >>> >>>>>>> >> >>> >>>>>>> Otherwise, I know we had a conversation at some point in the >> past >> >>> >> on >> >>> >>>> one >> >>> >>>>>>> of the lists about trying to factor out commonalities between >> >>> >>>>> jena-spatial >> >>> >>>>>>> and jena-text, but it didn't go very far at that time and I >> don't >> >>> >>> know >> >>> >>>>> what >> >>> >>>>>>> the intervening years have done to make it more or less >> feasible. >> >>> >>>> There >> >>> >>>>>>> have been many changes to jena-text in that time and the new >> >>> >> spatial >> >>> >>>>> module >> >>> >>>>>>> is a whole new story. I'd put a link here but searching >> >>> >>>>> lists.apache.org >> >>> >>>>>>> hasn't brought it up for me. >> >>> >>>>>>> >> >>> >>>>>>> ajs6f >> >>> >>>>>>> >> >>> >>>>>>> >> >>> >>>>>> >> >>> >>>>>> -- >> >>> >>>>>> Jean-Marc Vanel >> >>> >>>>>> >> >>> >>>>>> >> >>> >>>>> >> >>> >>>> >> >>> >>> >> >>> >> >> >>> >> http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me#subject >> >>> >>>>>> < >> >>> >>>>> >> >>> >>>> >> >>> >>> >> >>> >> >> >>> >> http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me >> >>> >>>>>> >> >>> >>>>>> Rule-based programming, Semantic Web >> >>> >>>>>> +33 (0)6 89 16 29 52 >> >>> >>>>>> Twitter: @jmvanel , @jmvanel_fr ; chat: irc:// >> >>> >>>> irc.freenode.net#eulergui >> >>> >>>>>> Chroniques jardin >> >>> >>>>>> < >> >>> >>>>> >> >>> >>>> >> >>> >>> >> >>> >> >> >>> >> http://semantic-forms.cc:1952/backlinks?q=http%3A%2F%2Fdbpedia.org%2Fresource%2FChronicle >> >>> >>>>>> >> >>> >>>>>> >> >>> >>>>> >> >>> >>>>> >> >>> >>>>> -- >> >>> >>>>> Jean-Marc Vanel >> >>> >>>>> >> >>> >>>>> >> >>> >>>> >> >>> >>> >> >>> >> >> >>> >> http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me#subject >> >>> >>>>> < >> >>> >>>>> >> >>> >>>> >> >>> >>> >> >>> >> >> >>> >> http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me >> >>> >>>>>> >> >>> >>>>> Rule-based programming, Semantic Web >> >>> >>>>> +33 (0)6 89 16 29 52 >> >>> >>>>> Twitter: @jmvanel , @jmvanel_fr ; chat: irc:// >> >>> >>> irc.freenode.net#eulergui >> >>> >>>>> Chroniques jardin >> >>> >>>>> < >> >>> >>>>> >> >>> >>>> >> >>> >>> >> >>> >> >> >>> >> http://semantic-forms.cc:1952/backlinks?q=http%3A%2F%2Fdbpedia.org%2Fresource%2FChronicle >> >>> >>>>>> >> >>> >>>>> >> >>> >>>> >> >>> >>>> >> >>> >>>> -- >> >>> >>>> >> >>> >>>> >> >>> >>>> --- >> >>> >>>> Marco Neumann >> >>> >>>> KONA >> >> >>> >>>> >> >>> >>> >> >>> >>> >> >>> >>> -- >> >>> >>> Jean-Marc Vanel >> >>> >>> >> >>> >>> >> >>> >> >> >>> >> http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me#subject >> >>> >>> < >> >>> >>> >> >>> >> >> >>> >> http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me >> >>> >>>> >> >>> >>> Rule-based programming, Semantic Web >> >>> >>> +33 (0)6 89 16 29 52 >> >>> >>> Twitter: @jmvanel , @jmvanel_fr ; chat: irc:// >> >>> irc.freenode.net#eulergui >> >>> >>> Chroniques jardin >> >>> >>> < >> >>> >>> >> >>> >> >> >>> >> http://semantic-forms.cc:1952/backlinks?q=http%3A%2F%2Fdbpedia.org%2Fresource%2FChronicle >> >>> >>>> >> >>> >>> >> >>> >> >> >>> >> >> >>> >> -- >> >>> >> >> >>> >> >> >>> >> --- >> >>> >> Marco Neumann >> >>> >> KONA >> >>> >> >> >>> > >> >>> > >> >>> >> >> >> >> >> >> -- >> >> Jean-Marc Vanel >> >> >> >> >> http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me#subject >> >> < >> http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me >> > >> >> Rule-based programming, Semantic Web >> >> +33 (0)6 89 16 29 52 >> >> Twitter: @jmvanel , @jmvanel_fr ; chat: irc:// >> irc.freenode.net#eulergui >> >> Chroniques jardin >> >> < >> http://semantic-forms.cc:1952/backlinks?q=http%3A%2F%2Fdbpedia.org%2Fresource%2FChronicle >> > >> >> >> > >> > >> > -- >> > Jean-Marc Vanel >> > >> > >> http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me#subject >> > < >> http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me >> > >> > Rule-based programming, Semantic Web >> > +33 (0)6 89 16 29 52 >> > Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui >> > Chroniques jardin >> > < >> http://semantic-forms.cc:1952/backlinks?q=http%3A%2F%2Fdbpedia.org%2Fresource%2FChronicle >> > >> > >> >> >> -- >> Jean-Marc Vanel >> >> http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me#subject >> < >> http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me >> > >> Rule-based programming, Semantic Web >> +33 (0)6 89 16 29 52 >> Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui >> Chroniques jardin >> < >> http://semantic-forms.cc:1952/backlinks?q=http%3A%2F%2Fdbpedia.org%2Fresource%2FChronicle >> > >> > > > -- > Jean-Marc Vanel > > http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me#subject > <http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me> > Rule-based programming, Semantic Web > +33 (0)6 89 16 29 52 > Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui > Chroniques jardin > <http://semantic-forms.cc:1952/backlinks?q=http%3A%2F%2Fdbpedia.org%2Fresource%2FChronicle> > -- Jean-Marc Vanel http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me#subject <http://www.semantic-forms.cc:9111/display?displayuri=http://jmvanel.free.fr/jmv.rdf%23me> Rule-based programming, Semantic Web +33 (0)6 89 16 29 52 Twitter: @jmvanel , @jmvanel_fr ; chat: irc://irc.freenode.net#eulergui Chroniques jardin <http://semantic-forms.cc:1952/backlinks?q=http%3A%2F%2Fdbpedia.org%2Fresource%2FChronicle>
