Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/* *##%
* ToPIA :: Service Index
* Copyright (C) 2004 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* ##%*/
/* *
* LuceneIndexer.java
*
* Created: 8 oct. 06 15:48:37
*
* @author poussin
* @version $Revision: 1459 $
*
* Last update: $Date: 2009-05-16 09:56:47 +0200 (Sat, 16 May 2009) $
* by : $Author: tchemit $
*/
package org.nuiton.topia.index;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.SortedSet;
import java.util.TreeSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.SimpleAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.Field.Index;
import org.apache.lucene.document.Field.Store;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.Searcher;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.NIOFSDirectory;
import org.apache.lucene.util.Version;
import org.hibernate.HibernateException;
import org.hibernate.metadata.ClassMetadata;
import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.persistence.TopiaId;
/**
* To use this indexer you must have two properties defined in config file:
*
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
*
*/
public class LuceneIndexer implements TopiaIndexImplementor {
/** to use log facility, just put in your code: log.info(\"...\"); */
static private Log log = LogFactory.getLog(LuceneIndexer.class);
private static final String TOPIA_ID = "topiaId";
protected File directory = null;
protected TopiaContextImplementor context;
/** contient les objets a reindexer car creer, modifier ou supprimer. key: id, value: fields values or null for deletion */
protected Map