<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hey<div>The more I think about the feature, the less I like it.</div><div><br></div><div>Here is what I have written in Hibernate Search in Action</div><div><br></div><div><div><i>Hibernate Search, by default, does not store null attributes into the index. Lucene does not have the notion of null fields, the field is simply not there. Hibernate Search could offer the ability (and most likely will in the future) to use a special string as a null marker to still be able to search by "null".</i></div><div><i>But before you jump at the Hibernate Search team throat, you need to understand why they have not offered this feature so far. Null is not a value per se. Null means that the data is not known (or does not make sense). Therefore, searching by null as if it was a value is somewhat odd. The authors are well aware that this is a raging debate especially amongst the relational model experts (see&nbsp;<a href="http://en.wikipedia.org/wiki/Null_%28SQL%29)">http://en.wikipedia.org/wiki/Null_%28SQL%29)</a>.</i></div><div><div><i>Whenever you feel the need for searching by "null", you should ask yourself if storing a special marker value in the database would make more sense. If you store a special marker value in the database, a lot of the "null"&nbsp;inconsistencies vanish. It also has the side effect of being queriable in Lucene and Hibernate Search.</i></div><div><br></div><div>So before we jump on the boat for this feature, I would like to know if people think it's still a good idea to offer this feature.</div><div><br></div><div>To answer your questions, the reason why I do not pass @Field but the raw set of data is because the @Field.index is translated into it's Lucene representation: some work is done.</div><div>Most people will write StringBridge implementation anyway where the null handling will be taken care of transparently (by&nbsp;String2FieldBridgeAdaptor).</div><div><br></div><div>I think I like 1 or 3. Note that get should be changed as well. Three is interesting indeed, rename it IndexingStragegy.</div></div></div><div><br></div><div><div>On &nbsp;Apr 21, 2008, at 10:07, Hardy Ferentschik wrote:<br><blockquote type="cite">Hi Emmanuel,<br><br>what's you take on this? Just adding another String parameter will work, but are we not getting too many parameters into the method? Wouldn't it be nicer to pass the actual @Field annotation. I think this might make things also clearer for the implementor of the interface.<br><br>I am also trying here to get a little into your head to understand your ideas behind the code design - hope<br>you don't mind ;-)<br><br>--Hardy<br><br><br><br>------- Forwarded message -------<br>From: "Hardy Ferentschik (JIRA)" &lt;<a href="mailto:noreply@atlassian.com">noreply@atlassian.com</a>><br>To: <a href="mailto:hardy@ferentschik.de">hardy@ferentschik.de</a><br>Subject: [Hibernate-JIRA] Commented: (HSEARCH-115) Add a default value for indexing null value<br>Date: Mon, 21 Apr 2008 14:04:33 +0200<br><br><br> &nbsp;&nbsp;&nbsp;[ <a href="http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-115?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_30032">http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-115?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_30032</a> ]<br><br>Hardy Ferentschik commented on HSEARCH-115:<br>-------------------------------------------<br><br>Ok, here are a few suggestions:<br><br>1. This is the simplest way. Basically just add a new property named 'indexNullAs' to @Field and @ClassBridge. Accordingly extend the FieldBridge interface to set(String name, Object value, Document document, Field.Store store, Field.Index index, Field.TermVector termVector, Float boost, String indexNullAs).<br><br>2. Alternatively one could change the FieldBridge API to actually pass in the Field annotation itself: set(String name, Object value, Document document, Field fieldAnnotation, &nbsp;Float boost). This would reduce the amount of parameters and might actually be more transparent for users implementing custom bridges. Unfortunately, one would have to introduce a ClassBridge interface as well in this case. I am not sure whether it is a good design choice to pass annotation instances around.<br><br>3. We ccould also change the API into something like this: set(String name, Object value, Document document, IndexProperties props), where IndexProperties is just a wrapper class for Field.Store, Field.Index, ... The drawback is that this just increases the number of classes.<br><br>Any comments?<br><br><blockquote type="cite">Add a default value for indexing null value<br></blockquote><blockquote type="cite">-------------------------------------------<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Key: HSEARCH-115<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;URL: <a href="http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-115">http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-115</a><br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Project: Hibernate Search<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Issue Type: Improvement<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Components: mapping<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Reporter: Julien Brulin<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Assignee: Hardy Ferentschik<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fix For: 3.1.0<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Hi,<br></blockquote><blockquote type="cite">Null elements are not indexed by lucene then it's not easy to use a nullable property in lucene query.<br></blockquote><blockquote type="cite">I have a TagTranslation entity in my model with a nullable property language. In this case null is used as default language for tag translation.<br></blockquote><blockquote type="cite">Each translation may have many variations like synonyms.<br></blockquote><blockquote type="cite">Because I can specified a default value for null value in the @Field annotation like this @Field(index=Index.UN_TOKENIZED, store=Store.NO, default='null'), i can't search a cat tag with a default translation like this : +value:cat* +lang:null<br></blockquote><blockquote type="cite">&lt;pre>&lt;/code><br></blockquote><blockquote type="cite">@Entity()<br></blockquote><blockquote type="cite">@Table(name="indexing_tag_trans")<br></blockquote><blockquote type="cite">@org.hibernate.annotations.Cache(usage=org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)<br></blockquote><blockquote type="cite">@Indexed<br></blockquote><blockquote type="cite">public class TagTranslation implements java.io.Serializable {<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre">        </span>private static final long serialVersionUID = -1065316566731456110L;<br></blockquote><blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre">        </span><br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;@Id<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;@GeneratedValue(strategy=GenerationType.IDENTITY)<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;@DocumentId<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;private Integer id;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre">        </span>@Field(index=Index.UN_TOKENIZED, store=Store.NO)<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;private String language;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;@Field(index=Index.TOKENIZED, store=Store.YES)<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;private String value;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY)<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;@org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;@JoinColumn(name="translation_id")<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;@IndexedEmbedded<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;private List&lt;TagVariation> variations = new LinkedList&lt;TagVariation>();<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;public TagTranslation() { }<br></blockquote><blockquote type="cite">...<br></blockquote><blockquote type="cite">&lt;/code><br></blockquote><blockquote type="cite">&lt;/pre><br></blockquote><blockquote type="cite">What do you think about that ?<br></blockquote><blockquote type="cite">Ps: sorry for english write, i am a french guy.<br></blockquote><br><br><br>-- <br>Hartmut Ferentschik<br>Ekholmsv.339 ,1, 127 45 Skärholmen, Sweden<br>Phone: &nbsp;+46 704 225 097 (m)<br></blockquote></div><br></div></body></html>