Table of Contents |
---|
Goals
User can specified specify fields in nested object to be indexed.
Query User can query on these nested fields as well as top level fields.
...
Code Block |
---|
/** * Create a lucene index using default analyzer. * @param luceneSerializer A callback which converts a region value to a * Lucene document or documents to be stored in the index. */ public void createIndex(String indexName, String regionPath, LuceneSerializer luceneSerializer); /** * An interface for writing the fields of an object into a lucene document * The region key will be added as a field to the returned documents. */ public interface LuceneSerializer { Collection<Document> toDocuments(Object value); } |
- Will We will provide a built-in implementation for LuceneSerializer. Use fieldnameAtLevel1.fieldnameAtLevel2 to specify a field in the nested object both for indexing and querying.
For example, a the following Customer object contains a Person field. A The Person object contains a Page field.
Code Block |
---|
public class Customer implements Serializable { private String name; private Person contact; // search nested object ...... } public class Person implements Serializable { private String name; private String email; private int revenue; private String address; private Page homepage; ....... } public class Page implements Serializable { private int id; // search integer in int format private String title; private String content; ...... } |
Following The following example demos demonstrates how to index on nested fields: contact.name, contact.email, contact.address, contact.homepage.title. Note: each segment is a field name, not a field type, because Customer class could have 2 Person fields: Person contact and Person deliveryman. Use field name is to identify the parent field.
...