org.nuiton.wikitty.storage.solr
Class WikittySearchEngineSolr

java.lang.Object
  extended by org.nuiton.wikitty.storage.solr.WikittySearchEngineSolr
All Implemented Interfaces:
WikittySolrConstant, WikittySearchEngine

public class WikittySearchEngineSolr
extends Object
implements WikittySearchEngine, WikittySolrConstant

Version:
$Revision: 1485 $ Last update: $Date: 2012-06-08 12:17:55 +0200 (Fri, 08 Jun 2012) $ by : $Author: bpoussin $
Author:
poussin

Field Summary
protected  org.nuiton.util.ApplicationConfig config
           
protected  ElementModifier elementModifier
          Field modifier use to transform to solr format
protected  FieldModifier fieldModifier
          Deprecated. 
protected  org.apache.solr.core.CoreContainer solrCore
          CoreContainer used to init the server and close it when finished
protected  SolrResource solrResource
          JTA resource
protected  org.apache.solr.client.solrj.SolrServer solrServer
          solr server
 
Fields inherited from interface org.nuiton.wikitty.storage.solr.WikittySolrConstant
SOLR_ALL_EXTENSIONS, SOLR_EXTENSIONS, SOLR_FULLTEXT, SOLR_FULLTEXT_ALL_EXTENSIONS, SOLR_ID, SOLR_NULL_FIELD, SOLR_QUERY_PARSER, SOLR_WIKITTY_PREFIX, SOLR_WIKITTY_SUFFIX, SUFFIX_BINARY, SUFFIX_BOOLEAN, SUFFIX_DATE, SUFFIX_NUMERIC, SUFFIX_SORTABLE, SUFFIX_STRING, SUFFIX_STRING_FULLTEXT, SUFFIX_STRING_LOWERCASE, SUFFIX_WIKITTY, TREENODE_ATTACHED, TREENODE_ATTACHED_ALL, TREENODE_DEPTH, TREENODE_PARENTS, TREENODE_PREFIX, TREENODE_ROOT
 
Constructor Summary
WikittySearchEngineSolr(org.nuiton.util.ApplicationConfig config, WikittyExtensionStorage extensionStorage)
          Init wikitty search engine on solr embedded server.
 
Method Summary
protected  void addToIndexDocument(org.apache.solr.common.SolrInputDocument doc, Wikitty w, String fqfieldName)
          modify one field in SolrInputDocument
protected  void addToIndexDocument(org.apache.solr.common.SolrInputDocument doc, WikittyTypes type, String fqfieldName, Object fieldValue, boolean collection)
          Ajoute un champs dans un document a indexer
protected  void addTreeIndexField(SolrResource solrResource, Map<String,org.apache.solr.common.SolrDocument> tree, AttachmentInTree attachmentInTree)
          Update attached extra field on all objects passed in argument allAttachmentToIndex
protected  void addTreeIndexField(SolrResource solrResource, org.apache.solr.common.SolrInputDocument doc, Map<String,org.apache.solr.common.SolrDocument> tree)
          Modifie/Ajoute les champs specifique a l'indexation des arbres sur les TreeNode.
 void clear(WikittyTransaction transaction)
           
protected  org.apache.solr.common.SolrInputDocument createIndexDocument(Wikitty w)
          Create all index document to used to modify indexation.
 void delete(WikittyTransaction transaction, Collection<String> ids)
          Plusieurs actions possibles en fontion du type d'objet: suppression d'un objet NON noeud suppression de cet objets suppression de cet objets dans les attachments des noeuds qui le contiennent suppression d'un noeud d'arbre suppression du noeud reindexation des noeuds qui le contenait comme parent suppression des attached sur les objets contenus dans les attachments de ce noeud reindexation des objets qui le contenait comme parent dans un champs attached
protected  void destroy()
          Method to destroy properly the search engine.
 PagedResult<String> findAllByCriteria(WikittyTransaction transaction, Criteria criteria)
           
 WikittyQueryResult<String> findAllByQuery(WikittyTransaction transaction, WikittyQuery query)
           
 TreeNodeResult<String> findAllChildrenCount(WikittyTransaction transaction, String wikittyId, int depth, boolean count, Criteria filter)
          Si l'argument n'est pas un TreeNode, une exception est levee
 WikittyQueryResultTreeNode<String> findAllChildrenCount(WikittyTransaction transaction, String wikittyId, int depth, boolean count, WikittyQuery filter)
          Si l'argument n'est pas un TreeNode, une exception est levee
 org.nuiton.util.ApplicationConfig getConfig()
           
 org.apache.solr.client.solrj.SolrServer getSolrServer()
           
 void store(WikittyTransaction transaction, Collection<Wikitty> wikitties, boolean force)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

config

protected org.nuiton.util.ApplicationConfig config

solrServer

protected org.apache.solr.client.solrj.SolrServer solrServer
solr server


fieldModifier

@Deprecated
protected FieldModifier fieldModifier
Deprecated. 
Field modifier use to transform to solr format


elementModifier

protected ElementModifier elementModifier
Field modifier use to transform to solr format


solrResource

protected SolrResource solrResource
JTA resource


solrCore

protected org.apache.solr.core.CoreContainer solrCore
CoreContainer used to init the server and close it when finished

Constructor Detail

WikittySearchEngineSolr

public WikittySearchEngineSolr(org.nuiton.util.ApplicationConfig config,
                               WikittyExtensionStorage extensionStorage)
Init wikitty search engine on solr embedded server.

Parameters:
extensionStorage - extension storage
config - app config (can be null)
Method Detail

getConfig

public org.nuiton.util.ApplicationConfig getConfig()

getSolrServer

public org.apache.solr.client.solrj.SolrServer getSolrServer()

clear

public void clear(WikittyTransaction transaction)
Specified by:
clear in interface WikittySearchEngine

store

public void store(WikittyTransaction transaction,
                  Collection<Wikitty> wikitties,
                  boolean force)
Specified by:
store in interface WikittySearchEngine

delete

public void delete(WikittyTransaction transaction,
                   Collection<String> ids)
            throws WikittyException
Plusieurs actions possibles en fontion du type d'objet:
  • suppression d'un objet NON noeud
  • suppression de cet objets
  • suppression de cet objets dans les attachments des noeuds qui le contiennent
  • suppression d'un noeud d'arbre
  • suppression du noeud
  • reindexation des noeuds qui le contenait comme parent
  • suppression des attached sur les objets contenus dans les attachments de ce noeud
  • reindexation des objets qui le contenait comme parent dans un champs attached
  • Specified by:
    delete in interface WikittySearchEngine
    Parameters:
    transaction - wikitty transaction
    ids - to deletes
    Throws:
    WikittyException

    addTreeIndexField

    protected void addTreeIndexField(SolrResource solrResource,
                                     org.apache.solr.common.SolrInputDocument doc,
                                     Map<String,org.apache.solr.common.SolrDocument> tree)
    Modifie/Ajoute les champs specifique a l'indexation des arbres sur les TreeNode. On se base sur le fait que si un TreeNode est dans SolrResource il ne peut etre que dans deux etats. Soit il a ete reindexe pour les arbres et il a les champs d'indexation arbre. Soit il a pas encore ete reindexe pour les arbres et dans ce cas il ne doit pas avoir les champs d'indexation d'arbre. (il est donc interdit d'avoir des champs d'indexation arbre obsolete si le document est dans SolrResource)

    Parameters:
    solrResource - solR resource
    doc - les documents representant le TreeNode
    tree - tous les autres noeuds d'arbre dont on pourrait avoir besoin pour l'indexation

    addTreeIndexField

    protected void addTreeIndexField(SolrResource solrResource,
                                     Map<String,org.apache.solr.common.SolrDocument> tree,
                                     AttachmentInTree attachmentInTree)
    Update attached extra field on all objects passed in argument allAttachmentToIndex

    Parameters:
    solrResource - must contains reindexed TreeNode, that contains attachment
    tree - solr document for some TreeNode (used when TreeNode not find in solrResource)
    attachmentInTree - attachment added and removed from TreeNode

    findAllByQuery

    public WikittyQueryResult<String> findAllByQuery(WikittyTransaction transaction,
                                                     WikittyQuery query)
    Specified by:
    findAllByQuery in interface WikittySearchEngine

    findAllChildrenCount

    public WikittyQueryResultTreeNode<String> findAllChildrenCount(WikittyTransaction transaction,
                                                                   String wikittyId,
                                                                   int depth,
                                                                   boolean count,
                                                                   WikittyQuery filter)
    Si l'argument n'est pas un TreeNode, une exception est levee

    Specified by:
    findAllChildrenCount in interface WikittySearchEngine
    Parameters:
    transaction - wikitty transaction
    wikittyId - l'objet root du resultat
    depth - profondeur souhaite pour la recherche des fils, ou -1 pour tous
    count - vrai si l'on souhaite avoir le nombre d'attachment associe au noeud retourne
    filter - filtre utilise pour compter le nombre d'attachment
    Returns:
    all childrens count

    addToIndexDocument

    protected void addToIndexDocument(org.apache.solr.common.SolrInputDocument doc,
                                      WikittyTypes type,
                                      String fqfieldName,
                                      Object fieldValue,
                                      boolean collection)
    Ajoute un champs dans un document a indexer


    addToIndexDocument

    protected void addToIndexDocument(org.apache.solr.common.SolrInputDocument doc,
                                      Wikitty w,
                                      String fqfieldName)
    modify one field in SolrInputDocument

    Parameters:
    doc - SolrInputDocument to modify
    w - wikitty used to find field value
    fqfieldName - field to index

    createIndexDocument

    protected org.apache.solr.common.SolrInputDocument createIndexDocument(Wikitty w)
    Create all index document to used to modify indexation. this method don't modify index. The document looks like : #id : wikittyId #extensions : extensionNames [fieldName] : [fieldValue] #null_field-[fieldname] : [true|false]

    Parameters:
    w - all wikitties object to index
    Returns:
    solrInputDocument used to modify index

    destroy

    protected void destroy()
    Method to destroy properly the search engine. Mainly used in tests


    findAllByCriteria

    public PagedResult<String> findAllByCriteria(WikittyTransaction transaction,
                                                 Criteria criteria)
    Specified by:
    findAllByCriteria in interface WikittySearchEngine

    findAllChildrenCount

    public TreeNodeResult<String> findAllChildrenCount(WikittyTransaction transaction,
                                                       String wikittyId,
                                                       int depth,
                                                       boolean count,
                                                       Criteria filter)
    Si l'argument n'est pas un TreeNode, une exception est levee

    Specified by:
    findAllChildrenCount in interface WikittySearchEngine
    Parameters:
    transaction - wikitty transaction
    wikittyId - l'objet root du resultat
    depth - profondeur souhaite pour la recherche des fils
    count - vrai si l'on souhaite avoir le nombre d'attachment associe au noeud retourne
    filter - filtre utilise pour compter le nombre d'attachment
    Returns:
    all childrens count


    Copyright © 2009-2012 CodeLutin. All Rights Reserved.