org.nuiton.wikitty.storage.solr
Class SolrUtil

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

public class SolrUtil
extends Object
implements WikittySolrConstant

Version:
$Revision: 1478 $ Last update: $Date: 2012-05-31 17:11:50 +0200 (Thu, 31 May 2012) $ by : $Author: bpoussin $
Author:
poussin

Field Summary
 
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
SolrUtil()
           
 
Method Summary
static Integer convertToInteger(Object value, String solrFieldName)
          Converti un Object en String, si l'objet est de type String un simple cast est fait, si l'objet est un tableau, on prend le 1er element, si le tableau contient plus de 1 element une exception est levee
static String convertToString(Object value, String solrFieldName)
          Converti un Object en String, si l'objet est de type String un simple cast est fait, si l'objet est un tableau, on prend le 1er element, si le tableau contient plus de 1 element une exception est levee
static void copySolrDocument(org.apache.solr.common.SolrDocument source, org.apache.solr.common.SolrInputDocument dest, String... fieldToInclude)
          Copy solr document
static void copySolrDocument(org.apache.solr.common.SolrDocument source, org.apache.solr.common.SolrInputDocument dest, String[] fieldToInclude, String[] fieldToExclude)
          Copy solr document
static void copySolrDocumentExcludeSomeField(org.apache.solr.common.SolrDocument source, org.apache.solr.common.SolrInputDocument dest, String... fieldToExclude)
          Copy solr document exlude some fields
static org.apache.solr.client.solrj.response.QueryResponse executeQuery(org.apache.solr.client.solrj.SolrServer solrServer, org.apache.solr.client.solrj.SolrQuery query)
          Execute SolrQuery on specified SolrServer and return the result
static Map<String,org.apache.solr.common.SolrDocument> findAllByAttachment(org.apache.solr.client.solrj.SolrServer solrServer, Collection<String> ids)
          Find solr document by TreeNode attachment field
static Map<String,org.apache.solr.common.SolrDocument> findAllByField(org.apache.solr.client.solrj.SolrServer solrServer, String solrField, Collection<String> ids)
          Find solr document by specified field in argument
static Map<String,org.apache.solr.common.SolrDocument> findAllById(org.apache.solr.client.solrj.SolrServer solrServer, Collection<String> ids)
          Find solr document by id
static Map<String,org.apache.solr.common.SolrDocument> findAllByParents(org.apache.solr.client.solrj.SolrServer solrServer, Collection<String> ids)
          Find solr document by TreeNode parents extra field
static org.apache.solr.common.SolrDocument findById(org.apache.solr.client.solrj.SolrServer solrServer, String id)
          Find solr document by id
static Set<String> getAttachedTreeNode(org.apache.solr.common.SolrDocument doc)
          Recherche tous les TreeNode auquel appartient en Attachment l'objet passe en parametre
static Integer getIntFieldValue(org.apache.solr.common.SolrDocument d, String fieldname)
          get value of field in SolrDocument, field must have only one value
static Integer getIntFieldValue(org.apache.solr.common.SolrDocument d, String fieldname, WikittyTypes type)
          get value of field in SolrDocument, field must have only one value
static Object getOneValue(Object value)
          If value is collection or array get only the first element, else juste return value.
static String getSolrFieldName(String fqfieldName, WikittyTypes type)
          if you change this method, change FieldModifier.convertToField(org.nuiton.wikitty.services.WikittyTransaction, java.lang.String) too
static String getStringFieldValue(org.apache.solr.common.SolrDocument d, String fieldname)
          get value of field in SolrDocument, field must have only one value
static String getStringFieldValue(org.apache.solr.common.SolrDocument d, String fieldname, WikittyTypes type)
          get value of field in SolrDocument, field must have only one value
static String getStringFieldValue(org.apache.solr.common.SolrInputDocument d, String fieldname)
          get value of field in SolrDocument, field must have only one value
static String getStringFieldValue(org.apache.solr.common.SolrInputDocument d, String fieldname, WikittyTypes type)
          get value of field in SolrDocument, field must have only one value
static Collection<String> getStringFieldValues(org.apache.solr.common.SolrDocument d, String fieldname)
           
static Collection<String> getStringFieldValues(org.apache.solr.common.SolrDocument d, String fieldname, WikittyTypes type)
           
static Collection<String> getStringFieldValues(org.apache.solr.common.SolrInputDocument d, String fieldname)
           
static Collection<String> getStringFieldValues(org.apache.solr.common.SolrInputDocument d, String fieldname, WikittyTypes type)
           
static String quoteForSolr(String s)
          Quote s for solr.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SolrUtil

public SolrUtil()
Method Detail

getAttachedTreeNode

public static Set<String> getAttachedTreeNode(org.apache.solr.common.SolrDocument doc)
Recherche tous les TreeNode auquel appartient en Attachment l'objet passe en parametre

Parameters:
doc - le document representant l'objet
Returns:
attached treeNodes
Since:
3.1

findById

public static org.apache.solr.common.SolrDocument findById(org.apache.solr.client.solrj.SolrServer solrServer,
                                                           String id)
Find solr document by id

Parameters:
solrServer - solR serveur
id - to find
Returns:
solR document found

findAllById

public static Map<String,org.apache.solr.common.SolrDocument> findAllById(org.apache.solr.client.solrj.SolrServer solrServer,
                                                                          Collection<String> ids)
Find solr document by id

Parameters:
solrServer - solR serveur
ids - to find
Returns:
solR documents found
Since:
3.1

findAllByParents

public static Map<String,org.apache.solr.common.SolrDocument> findAllByParents(org.apache.solr.client.solrj.SolrServer solrServer,
                                                                               Collection<String> ids)
Find solr document by TreeNode parents extra field

Parameters:
solrServer - solR server
ids - id that must be find in parents list
Returns:
Map key:TreeNode id, value; solr document associate with id
Since:
3.1

findAllByAttachment

public static Map<String,org.apache.solr.common.SolrDocument> findAllByAttachment(org.apache.solr.client.solrj.SolrServer solrServer,
                                                                                  Collection<String> ids)
Find solr document by TreeNode attachment field

Parameters:
solrServer - solR server
ids - id that must be find in attachment list
Returns:
Map key:TreeNode id, value; solr document associate with id
Since:
3.1

findAllByField

public static Map<String,org.apache.solr.common.SolrDocument> findAllByField(org.apache.solr.client.solrj.SolrServer solrServer,
                                                                             String solrField,
                                                                             Collection<String> ids)
Find solr document by specified field in argument

Parameters:
solrServer - solR serveur
solrField - field where we looking for ids
ids - ids that must be in solrField
Returns:
Map key:TreeNode id, value; solr document associate with id
Since:
3.1

executeQuery

public static org.apache.solr.client.solrj.response.QueryResponse executeQuery(org.apache.solr.client.solrj.SolrServer solrServer,
                                                                               org.apache.solr.client.solrj.SolrQuery query)
                                                                        throws org.apache.solr.client.solrj.SolrServerException
Execute SolrQuery on specified SolrServer and return the result

Parameters:
solrServer - solR server
query - to execute
Returns:
QueryResponse
Throws:
org.apache.solr.client.solrj.SolrServerException - if exception occured on request execution

getSolrFieldName

public static String getSolrFieldName(String fqfieldName,
                                      WikittyTypes type)
if you change this method, change FieldModifier.convertToField(org.nuiton.wikitty.services.WikittyTransaction, java.lang.String) too

Parameters:
fqfieldName - FQ field name
type - of field
Returns:
field name

copySolrDocument

public static void copySolrDocument(org.apache.solr.common.SolrDocument source,
                                    org.apache.solr.common.SolrInputDocument dest,
                                    String[] fieldToInclude,
                                    String[] fieldToExclude)
Copy solr document

Parameters:
source - solr document source
dest - solr document destination
fieldToInclude - only copy thes fields, if null or empty, copy all field
fieldToExclude - to not copy these fields

copySolrDocument

public static void copySolrDocument(org.apache.solr.common.SolrDocument source,
                                    org.apache.solr.common.SolrInputDocument dest,
                                    String... fieldToInclude)
Copy solr document

Parameters:
source - solr document source
dest - solr document destination
fieldToInclude - only copy this field, if null or empty, copy all field
Since:
3.1

copySolrDocumentExcludeSomeField

public static void copySolrDocumentExcludeSomeField(org.apache.solr.common.SolrDocument source,
                                                    org.apache.solr.common.SolrInputDocument dest,
                                                    String... fieldToExclude)
Copy solr document exlude some fields

Parameters:
source - solr document source
dest - solr document destination
fieldToExclude - not copy these fields
Since:
3.1

getStringFieldValues

public static Collection<String> getStringFieldValues(org.apache.solr.common.SolrDocument d,
                                                      String fieldname)

getStringFieldValues

public static Collection<String> getStringFieldValues(org.apache.solr.common.SolrInputDocument d,
                                                      String fieldname)

getStringFieldValues

public static Collection<String> getStringFieldValues(org.apache.solr.common.SolrDocument d,
                                                      String fieldname,
                                                      WikittyTypes type)

getStringFieldValues

public static Collection<String> getStringFieldValues(org.apache.solr.common.SolrInputDocument d,
                                                      String fieldname,
                                                      WikittyTypes type)

getStringFieldValue

public static String getStringFieldValue(org.apache.solr.common.SolrInputDocument d,
                                         String fieldname)
get value of field in SolrDocument, field must have only one value

Parameters:
d -
fieldname -
Returns:

getStringFieldValue

public static String getStringFieldValue(org.apache.solr.common.SolrInputDocument d,
                                         String fieldname,
                                         WikittyTypes type)
get value of field in SolrDocument, field must have only one value

Parameters:
d -
fieldname -
type - optional type to generate solr field name
Returns:

getStringFieldValue

public static String getStringFieldValue(org.apache.solr.common.SolrDocument d,
                                         String fieldname)
get value of field in SolrDocument, field must have only one value

Parameters:
d -
fieldname -
Returns:

getStringFieldValue

public static String getStringFieldValue(org.apache.solr.common.SolrDocument d,
                                         String fieldname,
                                         WikittyTypes type)
get value of field in SolrDocument, field must have only one value

Parameters:
d -
fieldname -
type - optional type to generate solr field name
Returns:

getIntFieldValue

public static Integer getIntFieldValue(org.apache.solr.common.SolrDocument d,
                                       String fieldname)
get value of field in SolrDocument, field must have only one value

Parameters:
d -
fieldname -
Returns:

getIntFieldValue

public static Integer getIntFieldValue(org.apache.solr.common.SolrDocument d,
                                       String fieldname,
                                       WikittyTypes type)
get value of field in SolrDocument, field must have only one value

Parameters:
d -
fieldname -
type - optional type to generate solr field name
Returns:

convertToString

public static String convertToString(Object value,
                                     String solrFieldName)
Converti un Object en String, si l'objet est de type String un simple cast est fait, si l'objet est un tableau, on prend le 1er element, si le tableau contient plus de 1 element une exception est levee

Parameters:
value -
Returns:
une string ou null si value est null ou est un tableau vide

convertToInteger

public static Integer convertToInteger(Object value,
                                       String solrFieldName)
Converti un Object en String, si l'objet est de type String un simple cast est fait, si l'objet est un tableau, on prend le 1er element, si le tableau contient plus de 1 element une exception est levee

Parameters:
value -
Returns:
une string ou null si value est null ou est un tableau vide

getOneValue

public static Object getOneValue(Object value)
If value is collection or array get only the first element, else juste return value.

Parameters:
value -
Returns:

quoteForSolr

public static String quoteForSolr(String s)
Quote s for solr. Currently only ':' is escaped

Parameters:
s - to quote
Returns:
new string solr compliant


Copyright © 2009-2012 CodeLutin. All Rights Reserved.