Index error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Index error

Jenny-2
Dear All,

I am writing an index for my project. Basically, I need to index documents
that have the following string parts

(s1=uri1, s2=url1##sameAs.org service@@url2##source KG owl:sameas@@).

To do so, I am using the following code:


TO ADD:

String urlString="subA"

String tmp = "url1##sameAs.org service@@url2##source KG owl:sameas@@"

        StringField url = new StringField("URL", urlAddress,
Field.Store.YES);

        StringField cSet = new StringField("ClassSet", tmp,
Field.Store.YES);

        doc.add(url);

        doc.add(cSet);

        indexWriter.addDocument(doc);

        indexWriter.commit();


TO GET:

//..prepare the query

        BooleanQuery query = new BooleanQuery();

        query.add(new TermQuery(new Term("URL", urlAddress)),
BooleanClause.Occur.MUST);

        //..find the docs by executing the query

        int hitsPerPage = 1;

        TopScoreDocCollector collector =
TopScoreDocCollector.create(hitsPerPage);

        searcher.search(query, collector);

        ScoreDoc[] hits = collector.topDocs().scoreDocs;

        if (hits.length > 0) {

            //..retrieve the related doc

            int docId = hits[0].doc;

            Document d = searcher.doc(docId);

            if (d != null) {

                ArrayList<TargetEntity> newTargetEntityList= new
ArrayList();

                //String cSet = d.get("ClassSet");

                String cSet = d.getField("ClassSet").stringValue();



                System.out.println("[addSbjSameAsListNew] URL =  "
+d.getField("URL").stringValue());

                System.out.println("[addSbjSameAsListNew] ClassSet FIELD =
" +d.getField("ClassSet").stringValue());



The point is that when testing it on the above example (urlString="subA"),
I get as output "url2##source KG owl:sameas@@"  and not  "url1##sameAs.org
service@@url2##source KG owl:sameas@@".

I tested the above example with both the StandardAnalyzer() and
KeywordAnalyzer() on the Lucene 5.5.4.



What is wrong? What am I missing?



Many Thanks in advance for your help.

Jenny
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Index error

Trejkaz
What if totalHits > 1?

TX

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...