code: protected void addAssociatedEntitiesToDocument(EntityMetadata metadata, Object entity, Document document,
          MetamodelImpl metaModel) {
          try {
              IndexCollection indexes = metadata.getEntityClazz().getAnnotation(IndexCollection.class);
              if (indexes != null) {
                  List<String> columnsNameToBeIndexed = new ArrayList<String>();
                  for (com.impetus.kundera.index.Index indexedColumn : indexes.columns()) {
                      Attribute attrib = metaModel.getEntityAttribute(entity.getClass(), indexedColumn.name());
                      columnsNameToBeIndexed.add(((AbstractAttribute) attrib).getJPAColumnName());
                  }
  
                  String indexName = metadata.getIndexName();
                  List<Relation> relations = metadata.getRelations();
                  for (Relation relation : relations) {
                      if (relation.getType().equals(ForeignKey.MANY_TO_ONE)
                          || relation.getType().equals(ForeignKey.ONE_TO_ONE)) {
                          String propertyName = relation.getJoinColumnName(null);
                          if (propertyName != null && columnsNameToBeIndexed.contains(propertyName)) {
                              java.lang.reflect.Field property = relation.getProperty();
                              Object obj = PropertyAccessorHelper.getObject(entity, property);
                              if (obj != null) {
                                  EntityMetadata relMetaData = metaModel.getEntityMetadata(obj.getClass());
                                  Object id = PropertyAccessorHelper.getId(obj, relMetaData);
                                  if (id != null) {
                                      Field luceneField =
                                          new Field(getCannonicalPropertyName(indexName, propertyName), id.toString(),
                                              Field.Store.YES, Field.Index.ANALYZED_NO_NORMS);
  
                                      document.add(luceneField);
                                  } else {
                                      LOG.warn("value is null for field" + property.getName());
                                  }
                              }
                          }
                      }
                  }
              }
          } catch (PropertyAccessException e) {
              LOG.error("Error in accessing field, Caused by:" + e.getMessage());
              throw new LuceneIndexingException("Error in creating indexes on associated columns", e);
          }
      }
docs: @param metadata
  @param entity
  @param document
  @param metaModel
  
  Add indexes for associated columns