Project

General

Profile

Download (1.33 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.hibernate.search;
10

    
11
import org.apache.lucene.document.Document;
12
import org.apache.lucene.document.Field;
13
import org.hibernate.search.bridge.FieldBridge;
14
import org.hibernate.search.bridge.LuceneOptions;
15
/**
16
 * Lucene index class bridge which sets class information for the objects into the index
17
 *
18
 * @author c.mathew
19
 * @version 1.0
20
 * @created 26 Jul 2013
21
 */
22
public class ClassInfoBridge implements FieldBridge {
23

    
24
	@Override
25
	public void set(String name, Object value, Document document,
26
			LuceneOptions luceneOptions) {
27
		Field nameField = new Field(name + ".name",
28
				value.getClass().getName(),
29
				luceneOptions.getStore(),
30
				luceneOptions.getIndex(),
31
				luceneOptions.getTermVector());
32
		nameField.setBoost(luceneOptions.getBoost());
33
		document.add(nameField);
34
		
35
		Field canonicalNameField = new Field(name + ".canonicalName",
36
				value.getClass().getCanonicalName(),
37
				luceneOptions.getStore(),
38
				luceneOptions.getIndex(),
39
				luceneOptions.getTermVector());
40
		canonicalNameField.setBoost(luceneOptions.getBoost());
41
		document.add(canonicalNameField);
42

    
43
	}
44
}
(3-3/14)