You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by bbarani <bb...@gmail.com> on 2010/12/10 23:20:32 UTC

Is it possible to assign default value for a particular record when using multivalued field type?

Hi,

I have a multivalued field for which some of the records have null or empty
data in it.

Since its difficult to parse and match empty XML tags in SOLR ouput, I
thought I would assign a default value for those empty data as below.

<field name="related_uid" type="string" indexed="true" stored="true"
multiValued="true" default="NODATA"/>

But my approach is not working if this field has atleast one data it. It
works fine if all the data for multi valued field is null.

For Ex:

If I am retreiving a data from a field called gender from backend and
assigning to this multivalued field(gender field in backend might contain
null too)

Data might be something lilke

Male
NULL
Female
Male

I am getting the XML output after indexing as 
- <arr name="related_name">
<str>Male</str> 
<str>Female</str> 
<str>Male</str> 
 </arr>


I want to get something like.

- <arr name="related_name">
<str>Male</str> 
<str>NODATA</str> 
<str>Female</str> 
<str>Male</str> 
 </arr>


Is it possible to implement this using SOLR default attribute?

Thanks,
Barani


-- 
View this message in context: http://lucene.472066.n3.nabble.com/Is-it-possible-to-assign-default-value-for-a-particular-record-when-using-multivalued-field-type-tp2066167p2066167.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Is it possible to assign default value for a particular record when using multivalued field type?

Posted by bbarani <bb...@gmail.com>.
Hi,

Is there a template transformer which can act on each and every record of
multivalued attribute?

The issue is that some of the records might have null data in source and I
want those data to be replaced with some default value.

Also if the value is blank I could just see <str/> in the XML. Any idea how
to parse this tag using SOLRNET?

The problem is that we are parsing the XML tag of 2 attribute (for ex:
objectid and objectname) and mapping it in the UI. Something like key value
pair.

If any one of the attribute (ex: in object name) is null or blank the
mapping order gets changed (b/w objectid and objectname).

I am not sure if the only solution is to handle in SOLR DIH query.

Thanks,
Barani
-- 
View this message in context: http://lucene.472066.n3.nabble.com/Is-it-possible-to-assign-default-value-for-a-particular-record-when-using-multivalued-field-type-tp2066167p2080890.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Is it possible to assign default value for a particular record when using multivalued field type?

Posted by bbarani <bb...@gmail.com>.
Hi,

Thanks a lot for your reply..

I am using database import handler to get the data (DIH) from DB.

When I get a null data in single valued attribute the 'default' attribute
seems to work perfectly fine.

But seems like I need to validate the Null value (like using case when else
statement) in query used in DIH when I am trying to assign it to multi
valued attribute..

Not sure if its the best way to resolve this issue.

Thanks,
Barani
-- 
View this message in context: http://lucene.472066.n3.nabble.com/Is-it-possible-to-assign-default-value-for-a-particular-record-when-using-multivalued-field-type-tp2066167p2067889.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Is it possible to assign default value for a particular record when using multivalued field type?

Posted by Tom Hill <so...@worldware.com>.
Could you give us a bit more information?

How are you getting this information into Solr? SolrJ?
DataImportHandler? It's hard to see where the null value is getting
dropped, if we don't know the path that it is coming in.

I suspect that the default attribute won't do it. It's possible that
you might be able to do something with an UpdateRequestProcessor. But
I'm afraid the null values may be gone by that point. If I knew how
you were getting the data in, it would be easier to check.

Tom


On Fri, Dec 10, 2010 at 2:20 PM, bbarani <bb...@gmail.com> wrote:
>
> Hi,
>
> I have a multivalued field for which some of the records have null or empty
> data in it.
>
> Since its difficult to parse and match empty XML tags in SOLR ouput, I
> thought I would assign a default value for those empty data as below.
>
> <field name="related_uid" type="string" indexed="true" stored="true"
> multiValued="true" default="NODATA"/>
>
> But my approach is not working if this field has atleast one data it. It
> works fine if all the data for multi valued field is null.
>
> For Ex:
>
> If I am retreiving a data from a field called gender from backend and
> assigning to this multivalued field(gender field in backend might contain
> null too)
>
> Data might be something lilke
>
> Male
> NULL
> Female
> Male
>
> I am getting the XML output after indexing as
> - <arr name="related_name">
> <str>Male</str>
> <str>Female</str>
> <str>Male</str>
>  </arr>
>
>
> I want to get something like.
>
> - <arr name="related_name">
> <str>Male</str>
> <str>NODATA</str>
> <str>Female</str>
> <str>Male</str>
>  </arr>
>
>
> Is it possible to implement this using SOLR default attribute?
>
> Thanks,
> Barani
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Is-it-possible-to-assign-default-value-for-a-particular-record-when-using-multivalued-field-type-tp2066167p2066167.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>