null value in SolrNet

547 views
Skip to first unread message

Joseph Freeman

unread,
May 16, 2011, 6:35:38 PM5/16/11
to solrnet
Say we have a class that has a property like:

public class SearchIndexData
{
[SolrField("myfield")]
public string MyField{ get; set; }
}

if I make a solrNet call like:

this.solrIndex.Add(new SearchIndexData() {MyField= null});

What does SolrNet actually send to solr to store?

1) field is not set in solr (IE: Queryable by: -myfield:[* TO *]
2) set to empty string "" Queryable by?
3) other?

And a solr specific question:
If we plan to have null fields in our indexed document, would it be
better performance to set these to a value like "-empty-" or "null"?
or does it matter? It would be ideal to query these fields with a
filter so that they are cached.

Any thoughts appreciated.

Thanks,
-Joe Freeman

Mauricio Scheffer

unread,
May 16, 2011, 7:52:02 PM5/16/11
to sol...@googlegroups.com
inline:

On Mon, May 16, 2011 at 7:35 PM, Joseph Freeman <j...@ironjelly.com> wrote:
Say we have a class that has a property like:

public class SearchIndexData
{
   [SolrField("myfield")]
   public string MyField{ get; set; }
}

if I make a solrNet call like:

this.solrIndex.Add(new SearchIndexData() {MyField= null});

What does SolrNet actually send to solr to store?

1) field is not set in solr (IE: Queryable by: -myfield:[*  TO *]
2) set to empty string "" Queryable by?
3) other?


1. This also applies to nullable types set to null (e.g. Nullable<int>)

 
And a solr specific question:
If we plan to have null fields in our indexed document, would it be
better performance to set these to a value like "-empty-" or "null"?
or does it matter? It would be ideal to query these fields with a
filter so that they are cached.


Semantically, if there is no value, then it should be null (i.e. field value not defined in Solr). From a performance perspective I doubt there is any significant difference, but if there is I'd say undefined field values aren't analysed (either at query or index time) and there is no "empty string" to cache either, so it should be marginally faster. But as I said, in practice I doubt it will make any significant difference, so I stick to what's semantically correct.

HTH

--
Mauricio
Reply all
Reply to author
Forward
0 new messages