org.nuiton.topia.index
Class LuceneIndexer

java.lang.Object
  extended by org.nuiton.topia.index.LuceneIndexer
All Implemented Interfaces:
TopiaService, TopiaIndexImplementor, TopiaIndexService

public class LuceneIndexer
extends java.lang.Object
implements TopiaIndexImplementor

To use this indexer you must have two properties defined in config file:

  • topia.index.engin=org.nuiton.topia.framework.LuceneIndexer
  • topia.index.lucene.directory=[/path/to/index/directory] Pour l'utilisation:
     SortedSet<IndexEntry> result = context.getIndexEngin().search("quelque chose")
     SortedSet<IndexEntry> result = context.getIndexEngin().search("class:org.nuiton.chorem.entities.Person name:poussin")
     // ou equivalent avec une map 
     Map m = new HashMap();
     m.put("class", "org.nuiton.chorem.entities.Person");
     m.put("name", "poussin");
     SortedSet<IndexEntry> result = context.getIndexEngin().search(m);
     

    Author:
    poussin

    Field Summary
    protected  TopiaContextImplementor context
               
    protected  java.io.File directory
               
    protected  java.util.Map<java.lang.Object,java.lang.Object[]> indexationMap
              contient les objets a reindexer car creer, modifier ou supprimer. key: id, value: fields values or null for deletion
     
    Fields inherited from interface org.nuiton.topia.index.TopiaIndexService
    SERVICE_NAME
     
    Constructor Summary
    LuceneIndexer()
               
     
    Method Summary
     void clearLastRecordedIndexation()
              called after commit and rollback to clear the modification record
     void doIndexation()
              This method is called after commit, to indicate to index all record entry add with addForIndexation method
     java.lang.Class<?>[] getPersistenceClasses()
               
     java.lang.String getServiceName()
               
     boolean postInit(TopiaContextImplementor context)
               
     boolean preInit(TopiaContextImplementor context)
               
     void recordForIndexation(java.lang.Object id, java.lang.Object[] fields)
              During object modification in transaction, this method is called to store all modification, but modification must no be done on index
     java.util.SortedSet<IndexEntry> search(java.util.Map query)
              Permet de faire une recherche
     java.util.SortedSet<IndexEntry> search(java.lang.String queryText)
              Permet de faire une recherche, par exemple: class:org.nuiton.chorem.entities.Person name:poussin
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    directory

    protected java.io.File directory

    context

    protected TopiaContextImplementor context

    indexationMap

    protected java.util.Map<java.lang.Object,java.lang.Object[]> indexationMap
    contient les objets a reindexer car creer, modifier ou supprimer. key: id, value: fields values or null for deletion

    Constructor Detail

    LuceneIndexer

    public LuceneIndexer()
    Method Detail

    getServiceName

    public java.lang.String getServiceName()
    Specified by:
    getServiceName in interface TopiaService

    getPersistenceClasses

    public java.lang.Class<?>[] getPersistenceClasses()
    Specified by:
    getPersistenceClasses in interface TopiaService

    recordForIndexation

    public void recordForIndexation(java.lang.Object id,
                                    java.lang.Object[] fields)
    Description copied from interface: TopiaIndexImplementor
    During object modification in transaction, this method is called to store all modification, but modification must no be done on index

    Specified by:
    recordForIndexation in interface TopiaIndexImplementor
    Parameters:
    id - topiaId object
    fields - object field value

    preInit

    public boolean preInit(TopiaContextImplementor context)
    Specified by:
    preInit in interface TopiaService

    postInit

    public boolean postInit(TopiaContextImplementor context)
    Specified by:
    postInit in interface TopiaService

    clearLastRecordedIndexation

    public void clearLastRecordedIndexation()
    Description copied from interface: TopiaIndexImplementor
    called after commit and rollback to clear the modification record

    Specified by:
    clearLastRecordedIndexation in interface TopiaIndexImplementor

    doIndexation

    public void doIndexation()
    Description copied from interface: TopiaIndexImplementor
    This method is called after commit, to indicate to index all record entry add with addForIndexation method

    Specified by:
    doIndexation in interface TopiaIndexImplementor

    search

    public java.util.SortedSet<IndexEntry> search(java.lang.String queryText)
    Description copied from interface: TopiaIndexService
    Permet de faire une recherche, par exemple: class:org.nuiton.chorem.entities.Person name:poussin

    Specified by:
    search in interface TopiaIndexService
    Returns:
    une list triée, le premier élement a le plus gros score

    search

    public java.util.SortedSet<IndexEntry> search(java.util.Map query)
    Description copied from interface: TopiaIndexService
    Permet de faire une recherche

    Specified by:
    search in interface TopiaIndexService
    Parameters:
    query - Map that contains field name as key and query in value for this field
    Returns:
    ?


    Copyright © 2004-2009 CodeLutin. All Rights Reserved.