If you make your EventListener implements SolrCoreAware you can get
hold of the core on inform. use that to get hold of the
SolrIndexWriter

On Wed, Jul 29, 2009 at 9:20 PM, Marc Sturlese<marc.sturl...@gmail.com> wrote:
>
> From the newSearcher(..) of a CustomEventListener which extends of
> AbstractSolrEventListener  can access to SolrIndexSearcher and all core
> properties but can't get a SolrIndexWriter. Do you now how can I get from
> there a SolrIndexWriter? This way I would be able to modify the documents (I
> need to modify them depending on values of other documents, that's why I
> can't do it with DIH delta-import).
> Thanks in advance
>
>
> Noble Paul നോബിള്‍  नोब्ळ्-2 wrote:
>>
>> On Tue, Jul 28, 2009 at 5:17 PM, Marc Sturlese<marc.sturl...@gmail.com>
>> wrote:
>>>
>>> That really sounds the best way to reach my goal. How could I invoque a
>>> listener from the newSearcher?Would be something like:
>>>    <listener event="newSearcher" class="solr.QuerySenderListener">
>>>      <arr name="queries">
>>>        <lst> <str name="q">solr</str> <str name="start">0</str> <str
>>> name="rows">10</str> </lst>
>>>        <lst> <str name="q">rocks</str> <str name="start">0</str> <str
>>> name="rows">10</str> </lst>
>>>        <lst><str name="q">static newSearcher warming query from
>>> solrconfig.xml</str></lst>
>>>      </arr>
>>>    </listener>
>>>    <listener event="newSearcher" class="solr.MyCustomListener">
>>>
>>> And MyCustomListener would be the class who open the reader:
>>>
>>>        RefCounted<SolrIndexSearcher> searchHolder = null;
>>>        try {
>>>          searchHolder = dataImporter.getCore().getSearcher();
>>>          IndexReader reader = searchHolder.get().getReader();
>>>
>>>          //Here I iterate over the reader doing docuemnt modifications
>>>
>>>        } finally {
>>>           if (searchHolder != null) searchHolder.decref();
>>>        }
>>>        } catch (Exception ex) {
>>>            LOG.info("error");
>>>        }
>>
>> you may not be able to access the DIH API from a newSearcher event .
>> But the API would give you the searcher directly as a method
>> parameter.
>>>
>>> Finally, to access to documents and add fields to some of them, I have
>>> thought in using SolrDocument classes. Can you please point me where
>>> something similar is done in solr source (I mean creation of
>>> SolrDocuemnts
>>> and conversion of them to proper lucene docuements).
>>>
>>> Does this way for reaching the goal makes sense?
>>>
>>> Thanks in advance
>>>
>>>
>>>
>>> Noble Paul നോബിള്‍  नोब्ळ्-2 wrote:
>>>>
>>>> when a core is reloaded the event fired is firstSearcher. newSearcher
>>>> is fired when a commit happens
>>>>
>>>>
>>>> On Tue, Jul 28, 2009 at 4:19 PM, Marc Sturlese<marc.sturl...@gmail.com>
>>>> wrote:
>>>>>
>>>>> Ok, but if I handle it in a newSearcher listener it will be executed
>>>>> every
>>>>> time I reload a core, isn't it? The thing is that I want to use an
>>>>> IndexReader to load in a HashMap some doc fields of the index and
>>>>> depending
>>>>> of the values of some field docs modify other docs. Its very memory
>>>>> consuming (I have tested it with a simple lucene script). Thats why I
>>>>> wanted
>>>>> to do it just after the indexing process.
>>>>>
>>>>> My ideal case would be to do it in the commit function of
>>>>> DirectUpdatehandler2.java just before
>>>>> writer.optimize(cmd.maxOptimizeSegments); is executed. But I don't want
>>>>> to
>>>>> mess that code... so trying to find out the best way to do that as a
>>>>> plugin
>>>>> instead of a hack as possible.
>>>>>
>>>>> Thanks in advance
>>>>>
>>>>>
>>>>> Noble Paul നോബിള്‍  नोब्ळ्-2 wrote:
>>>>>>
>>>>>> It is best handled as a 'newSearcher' listener in solrconfig.xml.
>>>>>> onImportEnd is invoked before committing
>>>>>>
>>>>>> On Tue, Jul 28, 2009 at 3:13 PM, Marc
>>>>>> Sturlese<marc.sturl...@gmail.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> Hey there,
>>>>>>> I would like to be able to do something like: After the indexing
>>>>>>> process
>>>>>>> is
>>>>>>> done with DIH I would like to open an indexreader, iterate over all
>>>>>>> docs,
>>>>>>> modify some of them depending on others and delete some others. I can
>>>>>>> easy
>>>>>>> do this directly coding with lucene but would like to know if there's
>>>>>>> a
>>>>>>> way
>>>>>>> to do it with Solr using SolrDocument or SolrInputDocument classes.
>>>>>>> I have thougth in using SolrJ or DIH listener onImportEnd but not
>>>>>>> sure
>>>>>>> if
>>>>>>> I
>>>>>>> can get an IndexReader in there.
>>>>>>> Any advice?
>>>>>>> Thanks in advance
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/update-some-index-documents-after-indexing-process-is-done-with-DIH-tp24695947p24695947.html
>>>>>>> Sent from the Solr - User mailing list archive at Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> -----------------------------------------------------
>>>>>> Noble Paul | Principal Engineer| AOL | http://aol.com
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/update-some-index-documents-after-indexing-process-is-done-with-DIH-tp24695947p24696872.html
>>>>> Sent from the Solr - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> -----------------------------------------------------
>>>> Noble Paul | Principal Engineer| AOL | http://aol.com
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/update-some-index-documents-after-indexing-process-is-done-with-DIH-tp24695947p24697751.html
>>> Sent from the Solr - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> -----------------------------------------------------
>> Noble Paul | Principal Engineer| AOL | http://aol.com
>>
>>
>
> --
> View this message in context: 
> http://www.nabble.com/update-some-index-documents-after-indexing-process-is-done-with-DIH-tp24695947p24722111.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>



-- 
-----------------------------------------------------
Noble Paul | Principal Engineer| AOL | http://aol.com

Reply via email to