diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/HibernateSearchDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/HibernateSearchDAO.java
index 6af50dd4f3cdd124bd0b0fe01cd7cb70ca1f325c..d5c771ffc4962a93c7eff695ab45ae916d8da231 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/HibernateSearchDAO.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/HibernateSearchDAO.java
@@ -19,9 +19,10 @@ package ch.systemsx.cisd.openbis.generic.server.dataaccess.db;
 import java.io.IOException;
 import java.sql.SQLException;
 import java.util.ArrayList;
-import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
@@ -495,11 +496,19 @@ final class HibernateSearchDAO extends HibernateDaoSupport implements IHibernate
 
         public String[] getIndexedFields()
         {
-            Collection<?> fieldNames = indexReader.getFieldNames(FieldOption.INDEXED);
-            // TODO 2008-11-27, Tomasz Pylak: get rid of hard-coded name. Specify the same name
-            // attribute for all DocumentId fields.
-            fieldNames.remove("id");
+            // WORKAROUND indexReader.getFieldNames doesn't really return unique field names
+            Set<String> fieldNames = new HashSet<String>();
+            for (Object fieldName : indexReader.getFieldNames(FieldOption.INDEXED))
+            {
+                fieldNames.add(fieldName.toString());
+            }
+
             fieldNames.remove(DocumentBuilder.CLASS_FIELDNAME);
+            fieldNames.remove(SearchFieldConstants.ID);
+            for (String prefix : SearchFieldConstants.PREFIXES)
+            {
+                fieldNames.remove(prefix + SearchFieldConstants.ID);
+            }
             return fieldNames.toArray(new String[fieldNames.size()]);
         }
 
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/DataPE.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/DataPE.java
index 408f204bf9b9ed53c239e0463c2f01ab45d0a66c..6db58ad0358ab30ad41ca8c9137f0a3aedb1fe5c 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/DataPE.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/DataPE.java
@@ -264,7 +264,13 @@ public class DataPE extends AbstractIdAndCodeHolder<DataPE> implements
     @Field(index = Index.UN_TOKENIZED, store = Store.YES, name = SearchFieldConstants.SAMPLE_ID)
     private Long getSampleId()
     {
-        return getSampleInternal() != null ? getSampleInternal().getId() : null;
+        Long result = null;
+        if (getSampleInternal() != null)
+        {
+            result = HibernateUtils.getId(getSampleInternal());
+            assert result != null;
+        }
+        return result;
     }
 
     /**
@@ -397,7 +403,7 @@ public class DataPE extends AbstractIdAndCodeHolder<DataPE> implements
     @Id
     @SequenceGenerator(name = SequenceNames.DATA_SEQUENCE, sequenceName = SequenceNames.DATA_SEQUENCE, allocationSize = 1)
     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SequenceNames.DATA_SEQUENCE)
-    @DocumentId
+    @DocumentId(name = SearchFieldConstants.ID)
     public Long getId()
     {
         return id;
@@ -446,7 +452,13 @@ public class DataPE extends AbstractIdAndCodeHolder<DataPE> implements
     @Field(index = Index.UN_TOKENIZED, store = Store.YES, name = SearchFieldConstants.EXPERIMENT_ID)
     private Long getExperimentId()
     {
-        return getExperimentInternal() != null ? getExperimentInternal().getId() : null;
+        Long result = null;
+        if (getExperimentInternal() != null)
+        {
+            result = HibernateUtils.getId(getExperimentInternal());
+            assert result != null;
+        }
+        return result;
     }
 
     private Set<DataSetPropertyPE> properties = new HashSet<DataSetPropertyPE>();
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/EntityPropertyPE.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/EntityPropertyPE.java
index 89854c8b58a921094a820589dbf1b0577ef62db1..0565185bea0c919123e65a751d3ff7cb0ff07714 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/EntityPropertyPE.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/EntityPropertyPE.java
@@ -41,6 +41,7 @@ import ch.systemsx.cisd.common.utilities.ClassUtils;
 import ch.systemsx.cisd.common.utilities.ModifiedShortPrefixToStringStyle;
 import ch.systemsx.cisd.openbis.generic.shared.IServer;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialIdentifier;
+import ch.systemsx.cisd.openbis.generic.shared.dto.hibernate.SearchFieldConstants;
 import ch.systemsx.cisd.openbis.generic.shared.dto.properties.EntityKind;
 import ch.systemsx.cisd.openbis.generic.shared.util.EqualsHashUtils;
 
@@ -102,8 +103,8 @@ public abstract class EntityPropertyPE extends HibernateAbstractRegistrationHold
             String fieldPrefix = name;
             String fieldFullName = fieldPrefix + getPropertyFieldName(entityProperty);
             Field field =
-                    new Field(fieldFullName, fieldValue, luceneOptions.getStore(), luceneOptions
-                            .getIndex());
+                    new Field(fieldFullName, fieldValue, luceneOptions.getStore(),
+                            luceneOptions.getIndex());
             if (luceneOptions.getBoost() != null)
             {
                 field.setBoost(luceneOptions.getBoost());
@@ -148,7 +149,7 @@ public abstract class EntityPropertyPE extends HibernateAbstractRegistrationHold
 
     @ManyToOne(fetch = FetchType.EAGER)
     @JoinColumn(name = ColumnNames.VOCABULARY_TERM_COLUMN)
-    @IndexedEmbedded
+    @IndexedEmbedded(prefix = SearchFieldConstants.PREFIX_VOCABULARY_TERM)
     public VocabularyTermPE getVocabularyTerm()
     {
         return vocabularyTerm;
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/ExperimentPE.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/ExperimentPE.java
index 5c7b7881e6d9b9e78acad5617da9e430442c417d..27582060753703506589fbb812e50b4549d03e81 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/ExperimentPE.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/ExperimentPE.java
@@ -163,7 +163,7 @@ public class ExperimentPE extends AttachmentHolderPE implements
     @Id
     @SequenceGenerator(name = SequenceNames.EXPERIMENT_SEQUENCE, sequenceName = SequenceNames.EXPERIMENT_SEQUENCE, allocationSize = 1)
     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SequenceNames.EXPERIMENT_SEQUENCE)
-    @DocumentId
+    @DocumentId(name = SearchFieldConstants.ID)
     public Long getId()
     {
         return id;
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/MaterialPE.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/MaterialPE.java
index e4e9010bb38b3c49c89ab1b6591e4452c0d80dbe..f3eba2690f95d03dfb10a775b1246f3c6d33840f 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/MaterialPE.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/MaterialPE.java
@@ -152,7 +152,8 @@ public class MaterialPE implements IIdAndCodeHolder, Comparable<MaterialPE>,
     @Id
     @SequenceGenerator(name = SequenceNames.MATERIAL_SEQUENCE, sequenceName = SequenceNames.MATERIAL_SEQUENCE, allocationSize = 1)
     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SequenceNames.MATERIAL_SEQUENCE)
-    @DocumentId
+    @DocumentId(name = SearchFieldConstants.ID)
+
     public Long getId()
     {
         return id;
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SamplePE.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SamplePE.java
index df67e93eb884139566a31ca43307de9f921c574c..4b3ba8ebb3f5333b7cdc8be9e9e260806394b2ab 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SamplePE.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SamplePE.java
@@ -467,7 +467,13 @@ public class SamplePE extends AttachmentHolderPE implements IIdAndCodeHolder, Co
     @Field(index = Index.UN_TOKENIZED, store = Store.YES, name = SearchFieldConstants.EXPERIMENT_ID)
     private Long getExperimentId()
     {
-        return getExperimentInternal() != null ? getExperimentInternal().getId() : null;
+        Long result = null;
+        if (getExperimentInternal() != null)
+        {
+            result = HibernateUtils.getId(getExperimentInternal());
+            assert result != null;
+        }
+        return result;
     }
 
     //
@@ -477,7 +483,7 @@ public class SamplePE extends AttachmentHolderPE implements IIdAndCodeHolder, Co
     @SequenceGenerator(name = SequenceNames.SAMPLE_SEQUENCE, sequenceName = SequenceNames.SAMPLE_SEQUENCE, allocationSize = 1)
     @Id
     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SequenceNames.SAMPLE_SEQUENCE)
-    @DocumentId
+    @DocumentId(name = SearchFieldConstants.ID)
     public final Long getId()
     {
         return id;
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/hibernate/SearchFieldConstants.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/hibernate/SearchFieldConstants.java
index e62d9de685213df1483a685308e95c5524a691e7..96d4ca08b1ed6a9debd4177ec842462216c916a2 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/hibernate/SearchFieldConstants.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/hibernate/SearchFieldConstants.java
@@ -48,6 +48,19 @@ public final class SearchFieldConstants
 
     public static final String PREFIX_ATTACHMENT = "attachment" + SEPARATOR;
 
+    public static final String PREFIX_VOCABULARY_TERM = "vocabulary term" + SEPARATOR;
+
+    public static final String[] PREFIXES =
+        { PREFIX_PROPERTIES, PREFIX_EXPERIMENT, PREFIX_SAMPLE, PREFIX_ENTITY_TYPE,
+                PREFIX_FILE_FORMAT_TYPE, PREFIX_FILE_FORMAT_TYPE, PREFIX_PROJECT, PREFIX_SPACE,
+                PREFIX_REGISTRATOR, PREFIX_ATTACHMENT, PREFIX_PROPERTIES + PREFIX_VOCABULARY_TERM };
+
+    public static final String ID = "id";
+
+    public static final String EXPERIMENT_ID = PREFIX_EXPERIMENT + ID;
+
+    public static final String SAMPLE_ID = PREFIX_SAMPLE + ID;
+
     public static final String DELETED = "deleted";
 
     public static final String PERSON_LAST_NAME = "Last Name";
@@ -58,8 +71,6 @@ public final class SearchFieldConstants
 
     public static final String PERSON_USER_ID = "User Id";
 
-    public static final String ID = "id";
-
     public static final String CODE = "code";
 
     public static final String PERM_ID = "perm_id";
@@ -72,8 +83,4 @@ public final class SearchFieldConstants
 
     public static final String FILE_DESCRIPTION = "description";
 
-    public static final String EXPERIMENT_ID = "experiment_id";
-
-    public static final String SAMPLE_ID = "sample_id";
-
 }