Thanks Mr. Ephraim Ofir. I used the SELECT IF() for my requirement. The query result is correct. But when i see it in my index, the value stored is something unusual bunch of characters e.g. "*...@6628ad5a"*
Please suggest as to what went wrong. - Pawan On Mon, Oct 25, 2010 at 6:44 PM, Ephraim Ofir <ephra...@icq.com> wrote: > Assuming you're talking about data that comes from a DB, I find it easiest > to do this kind of logic on the DB's side (mssql example): > SELECT IF(someField = someValue, desiredValue, NULL) AS desiredName from > someTable > > If that's not possible, you can use RegexTransformer( > http://wiki.apache.org/solr/DataImportHandler#RegexTransformer) or (worst > case and worst performance) ScriptTransformer( > http://wiki.apache.org/solr/DataImportHandler#ScriptTransformer) and > actually write a JS script to do your logic. > > Ephraim Ofir > > -----Original Message----- > From: Jan Høydahl / Cominvent [mailto:jan....@cominvent.com] > Sent: Monday, October 25, 2010 10:23 AM > To: solr-user@lucene.apache.org > Subject: Re: How to index on basis of a condition? > > Do you want to use a field's content do decide whether the document should > be indexed or not? > You could write an UpdateProcessor for that, simply aborting the chain for > the docs that don't pass your test. > > @Override > public void processAdd(AddUpdateCommand cmd) throws IOException { > SolrInputDocument doc = cmd.getSolrInputDocument(); > String value = (String) doc.getFieldValue("myfield"); > String condition = "foobar"; > if(value == condition) { > super.processAdd(cmd); > } > } > > But if what you meant was to skip only that field if it does not match > condition, you could use doc.removeField(name) instead. Now you can feed > your content using whatever method you like. > > -- > Jan Høydahl, search solution architect > Cominvent AS - www.cominvent.com > > On 25. okt. 2010, at 08.38, Pawan Darira wrote: > > > Hi > > > > I want to index a particular field on one if() condition. Can i do it > > through DIH? > > > > Please suggest. > > > > -- > > Thanks, > > Pawan Darira > > -- Thanks, Pawan Darira