Dear Chris,
Hi,
Thank you for your response. Actually I implemented a small code for the
purpose of extracting article keywords out of Lucene index on commit,
optimize or calling the specific query. I did implement that using search
component. I know that the searchComponent is not for the purpose of
updating index, but it was suggested in Solr mailing list at the first
place and it seems it is the most possible solution according to Solr
extension points. Anyway for more information about why I chose
searchComponent at the first place please take a look at this
<https://mail-archives.apache.org/mod_mbox/lucene-solr-user/201503.mbox/browser>
link.

Best regards.


On Wed, Apr 15, 2015 at 10:00 PM, Chris Hostetter <hossman_luc...@fucit.org>
wrote:

>
> the short answer is that you need something to re-open the searcher -- but
> i'm not going to go into specifics on how to do that because...
>
> You are dealing with a VERY low level layer of the lucene/solr code stack
> -- w/o more details on why you've written this particular bit of code (and
> where in the solr stack this code lives) it's hard to give you general
> advice on the best way to proceed and i don't wnat to encourage you along
> a dangerous path when there are likely much
> easier/better/safer/more-supported ways to do what you are trying to do --
> you just need to explain to us what that is.
>
> https://people.apache.org/~hossman/#xyproblem
> XY Problem
>
> Your question appears to be an "XY Problem" ... that is: you are dealing
> with "X", you are assuming "Y" will help you, and you are asking about "Y"
> without giving more details about the "X" so that we can understand the
> full issue.  Perhaps the best solution doesn't involve "Y" at all?
> See Also: http://www.perlmonks.org/index.pl?node_id=542341
>
>
>
>
> : Date: Thu, 9 Apr 2015 01:02:16 +0430
> : From: Ali Nazemian <alinazem...@gmail.com>
> : Reply-To: solr-user@lucene.apache.org
> : To: "solr-user@lucene.apache.org" <solr-user@lucene.apache.org>
> : Subject: Lucene updateDocument does not affect index until restarting
> solr
> :
> : Dear all,
> : Hi,
> : As a part of my code I have to update Lucene document. For this purpose I
> : used writer.updateDocument() method. My problem is the update process is
> : not affect index until restarting Solr. Would you please tell me what
> part
> : of my code is wrong? Or what should I add in order to apply the changes?
> :
> : RefCounted<IndexWriter> iw = solrCoreState.getIndexWriter(core);
> :       try {
> :         IndexWriter writer = iw.get();
> :         FieldType type= new FieldType(StringField.TYPE_STORED);
> :         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 Field(keywordField, word, type));
> :           }
> :           String uniqueKey =
> : searcher.getSchema().getUniqueKeyField().getName();
> :           writer.updateDocument(new Term(uniqueKey,
> : document.get(uniqueKey)),
> :               document);
> :         }
> :         writer.commit();
> :       } finally {
> :         iw.decref();
> :       }
> :
> :
> : Best regards.
> :
> : --
> : A.Nazemian
> :
>
> -Hoss
> http://www.lucidworks.com/
>



-- 
A.Nazemian

Reply via email to