Dear Upayavira,
Hi,
It is just the part of my code in which caused the problem. I know
searchComponent is not for changing the index, but for the purpose of
extracting document keywords I was forced to hack searchComponent for
extracting keywords and putting them into index.
For more information about why I chose searchComponent at the first place
please follow this link:
https://mail-archives.apache.org/mod_mbox/lucene-solr-user/201503.mbox/browser

Best regards.


On Tue, Apr 7, 2015 at 5:30 PM, Upayavira <u...@odoko.co.uk> wrote:

> What are you trying to do? A search component is not intended for
> updating the index, so it really doesn’t surprise me that you aren’t
> seeing updates.
>
> I’d suggest you describe the problem you are trying to solve before
> proposing solutions.
>
> Upayavira
>
>
> On Tue, Apr 7, 2015, at 01:32 PM, Ali Nazemian wrote:
> > I implement a small code for the purpose of extracting some keywords out
> > of
> > Lucene index. I did implement that using search component. My problem is
> > when I tried to update Lucene IndexWriter, Solr index which is placed on
> > top of that, does not affect. As you can see I did the commit part.
> >
> >     BooleanQuery query = new BooleanQuery();
> >         for (String fieldName : keywordSourceFields) {
> >           TermQuery termQuery = new TermQuery(new Term(fieldName,"N/A"));
> >           query.add(termQuery, Occur.MUST_NOT);
> >         }
> >         TermQuery termQuery=new TermQuery(new Term(keywordField, "N/A"));
> >         query.add(termQuery, Occur.MUST);
> >         try {
> >           //Query q= new QueryParser(keywordField, new
> > StandardAnalyzer()).parse(query.toString());
> >           TopDocs results = searcher.search(query,
> >               maxNumDocs);
> >           ScoreDoc[] hits = results.scoreDocs;
> >           IndexWriter writer = getLuceneIndexWriter(searcher.getPath());
> >           for (int i = 0; i < hits.length; i++) {
> >             Document document = searcher.doc(hits[i].doc);
> >             List<String> keywords = keyword.getKeywords(hits[i].doc);
> >             if(keywords.size()>0) document.removeFields(keywordField);
> >             for (String word : keywords) {
> >               document.add(new StringField(keywordField, word,
> > Field.Store.YES));
> >             }
> >             String uniqueKey =
> > searcher.getSchema().getUniqueKeyField().getName();
> >             writer.updateDocument(new Term(uniqueKey,
> > document.get(uniqueKey)),
> >                 document);
> >           }
> >           writer.commit();
> >           writer.forceMerge(1);
> >           writer.close();
> >         } catch (IOException | SyntaxError e) {
> >           throw new RuntimeException();
> >         }
> >
> > Please help me through solving this problem.
> >
> > --
> > A.Nazemian
>



-- 
A.Nazemian

Reply via email to