Java Doc for SolrPluginUtils.java in  » Search-Engine » apache-solr-1.2.0 » org » apache » solr » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Search Engine » apache solr 1.2.0 » org.apache.solr.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.solr.util.SolrPluginUtils

SolrPluginUtils
public class SolrPluginUtils (Code)

Utilities that may be of use to RequestHandlers.

Many of these functions have code that was stolen/mutated from StandardRequestHandler.

:TODO: refactor StandardRequestHandler to use these utilities

:TODO: Many "standard" functionality methods are not cognisant of default parameter settings.


Inner Class :public static class DisjunctionMaxQueryParser extends SolrQueryParser
Inner Class :public static class IdentityRegenerator implements CacheRegenerator

Field Summary
public static  StringFL
    


Method Summary
static  intcalculateMinShouldMatch(int optionalClauseCount, String spec)
    
public static  DocListdoSimpleQuery(String sreq, SolrIndexSearcher searcher, IndexSchema schema, int start, int limit)
    
public static  NamedListdoStandardDebug(SolrQueryRequest req, String userQuery, Query query, DocList results, CommonParams params)
    

Returns a NamedList containing many "standard" pieces of debugging information.

public static  NamedListdoStandardDebug(SolrQueryRequest req, String userQuery, Query query, DocList results)
    

Returns a NamedList containing many "standard" pieces of debugging information.

public static  voidflattenBooleanQuery(BooleanQuery to, BooleanQuery from)
     Recursively walks the "from" query pulling out sub-queries and adding them to the "to" query.

Boosts are multiplied as needed.

public static  booleangetBooleanParam(SolrQueryRequest req, String param, boolean def)
     Treats parameter value as a boolean.
public static  NamedListgetExplainList(Query query, DocList docs, SolrIndexSearcher searcher, IndexSchema schema)
     Generates an list of Explanations for each item in a list of docs.
public static  NumbergetNumberParam(SolrQueryRequest req, String param, Number def)
     Treats the param value as a Number, returns the default if nothing is there or if it's not a number.
public static  StringgetParam(SolrQueryRequest req, String param, String def)
     Returns the param, or the default if it's empty or not specified.
public static  SortgetSort(SolrQueryRequest req)
    
public static  intnumDocs(SolrIndexSearcher s, Query q, Query f)
     SolrIndexSearch.numDocs(Query,Query) freaks out if the filtering query is null, so we use this workarround.
public static  voidoptimizePreFetchDocs(DocList docs, Query query, SolrQueryRequest req, SolrQueryResponse res)
     Pre-fetch documents into the index searcher's document cache. This is an entirely optional step which you might want to perform for the following reasons:
  • Locates the document-retrieval costs in one spot, which helps detailed performance measurement
  • Determines a priori what fields will be needed to be fetched by various subtasks, like response writing and highlighting.
public static  Map<String, Float>parseFieldBoosts(String in)
     Given a string containing fieldNames and boost info, converts it to a Map from field name to boost info.
public static  Map<String, Float>parseFieldBoosts(String[] fieldLists)
     Like parseFieldBoosts(String), but parses all the strings in the provided array (which may be null).
Parameters:
  fieldLists - an array of Strings eg.
public static  List<Query>parseFilterQueries(SolrQueryRequest req)
    
public static  List<Query>parseFuncs(IndexSchema s, String in)
     Given a string containing functions with optional boosts, returns an array of Queries representing those functions with the specified boosts.
public static  List<Query>parseQueryStrings(SolrQueryRequest req, String[] queries)
     Turns an array of query strings into a List of Query objects.
public static  CharSequencepartialEscape(CharSequence s)
    
public static  voidsetDefaults(SolrQueryRequest req, SolrParams defaults)
     Set defaults on a SolrQueryRequest.
public static  voidsetDefaults(SolrQueryRequest req, SolrParams defaults, SolrParams appends, SolrParams invariants)
     Set default-ish params on a SolrQueryRequest.
public static  voidsetMinShouldMatch(BooleanQuery q, String spec)
     Checks the number of optional clauses in the query, and compares it with the specification string to determine the proper value to use.
public static  intsetReturnFields(SolrQueryRequest req, SolrQueryResponse res)
    
public static  intsetReturnFields(String fl, SolrQueryResponse res)
     Given a space seperated list of field names, sets the field list on the SolrQueryResponse.
public static  String[]split(String value)
     Split a value that may contain a comma, space of bar separated list.
public static  CharSequencestripUnbalancedQuotes(CharSequence s)
     Returns it's input if there is an even (ie: balanced) number of '"' characters -- otherwise returns a String in which all '"' characters are striped out.

Field Detail
FL
public static String FL(Code)
standard param for field list





Method Detail
calculateMinShouldMatch
static int calculateMinShouldMatch(int optionalClauseCount, String spec)(Code)
helper exposed for UnitTests
See Also:   SolrPluginUtils.setMinShouldMatch



doSimpleQuery
public static DocList doSimpleQuery(String sreq, SolrIndexSearcher searcher, IndexSchema schema, int start, int limit) throws IOException(Code)
Executes a basic query in lucene syntax



doStandardDebug
public static NamedList doStandardDebug(SolrQueryRequest req, String userQuery, Query query, DocList results, CommonParams params) throws IOException(Code)

Returns a NamedList containing many "standard" pieces of debugging information.

  • rawquerystring - the 'q' param exactly as specified by the client
  • querystring - the 'q' param after any preprocessing done by the plugin
  • parsedquery - the main query executed formated by the Solr QueryParsing utils class (which knows about field types)
  • parsedquery_toString - the main query executed formated by it's own toString method (in case it has internal state Solr doesn't know about)
  • expain - the list of score explanations for each document in results against query.
  • otherQuery - the query string specified in 'explainOther' query param.
  • explainOther - the list of score explanations for each document in results against 'otherQuery'

Parameters:
  req - the request we are dealing with
Parameters:
  userQuery - the users query as a string, after any basicpreprocessing has been done
Parameters:
  query - the query built from the userQuery(and perhaps other clauses) that identifies the mainresult set of the response.
Parameters:
  results - the main result set of the response



doStandardDebug
public static NamedList doStandardDebug(SolrQueryRequest req, String userQuery, Query query, DocList results) throws IOException(Code)

Returns a NamedList containing many "standard" pieces of debugging information.

  • rawquerystring - the 'q' param exactly as specified by the client
  • querystring - the 'q' param after any preprocessing done by the plugin
  • parsedquery - the main query executed formated by the Solr QueryParsing utils class (which knows about field types)
  • parsedquery_toString - the main query executed formated by it's own toString method (in case it has internal state Solr doesn't know about)
  • expain - the list of score explanations for each document in results against query.
  • otherQuery - the query string specified in 'explainOther' query param.
  • explainOther - the list of score explanations for each document in results against 'otherQuery'

Parameters:
  req - the request we are dealing with
Parameters:
  userQuery - the users query as a string, after any basicpreprocessing has been done
Parameters:
  query - the query built from the userQuery(and perhaps other clauses) that identifies the mainresult set of the response.
Parameters:
  results - the main result set of the response



flattenBooleanQuery
public static void flattenBooleanQuery(BooleanQuery to, BooleanQuery from)(Code)
Recursively walks the "from" query pulling out sub-queries and adding them to the "to" query.

Boosts are multiplied as needed. Sub-BooleanQueryies which are not optional will not be flattened. From will be mangled durring the walk, so do not attempt to reuse it.




getBooleanParam
public static boolean getBooleanParam(SolrQueryRequest req, String param, boolean def)(Code)
Treats parameter value as a boolean. The string 'false' is false; any other non-empty string is true.



getExplainList
public static NamedList getExplainList(Query query, DocList docs, SolrIndexSearcher searcher, IndexSchema schema) throws IOException(Code)
Generates an list of Explanations for each item in a list of docs.
Parameters:
  query - The Query you want explanations in the context of
Parameters:
  docs - The Documents you want explained relative that query



getNumberParam
public static Number getNumberParam(SolrQueryRequest req, String param, Number def)(Code)
Treats the param value as a Number, returns the default if nothing is there or if it's not a number.



getParam
public static String getParam(SolrQueryRequest req, String param, String def)(Code)
Returns the param, or the default if it's empty or not specified.



getSort
public static Sort getSort(SolrQueryRequest req)(Code)
Determines the correct Sort based on the request parameter "sort" null if no sort is specified.



numDocs
public static int numDocs(SolrIndexSearcher s, Query q, Query f) throws IOException(Code)
SolrIndexSearch.numDocs(Query,Query) freaks out if the filtering query is null, so we use this workarround.



optimizePreFetchDocs
public static void optimizePreFetchDocs(DocList docs, Query query, SolrQueryRequest req, SolrQueryResponse res) throws IOException(Code)
Pre-fetch documents into the index searcher's document cache. This is an entirely optional step which you might want to perform for the following reasons:
  • Locates the document-retrieval costs in one spot, which helps detailed performance measurement
  • Determines a priori what fields will be needed to be fetched by various subtasks, like response writing and highlighting. This minimizes the chance that many needed fields will be loaded lazily. (it is more efficient to load all the field we require normally).
If lazy field loading is disabled, this method does nothing.



parseFieldBoosts
public static Map<String, Float> parseFieldBoosts(String in)(Code)
Given a string containing fieldNames and boost info, converts it to a Map from field name to boost info.

Doesn't care if boost info is negative, you're on your own.

Doesn't care if boost info is missing, again: you're on your own.


Parameters:
  in - a String like "fieldOne^2.3 fieldTwo fieldThree^-0.4" Map of fieldOne => 2.3, fieldTwo => null, fieldThree => -0.4



parseFieldBoosts
public static Map<String, Float> parseFieldBoosts(String[] fieldLists)(Code)
Like parseFieldBoosts(String), but parses all the strings in the provided array (which may be null).
Parameters:
  fieldLists - an array of Strings eg. {"fieldOne^2.3", "fieldTwo"} Map of fieldOne => 2.3, fieldThree => -0.4



parseFilterQueries
public static List<Query> parseFilterQueries(SolrQueryRequest req) throws ParseException(Code)
Builds a list of Query objects that should be used to filter results
See Also:   SolrParams.FQ null if no filter queries



parseFuncs
public static List<Query> parseFuncs(IndexSchema s, String in) throws ParseException(Code)
Given a string containing functions with optional boosts, returns an array of Queries representing those functions with the specified boosts.

NOTE: intra-function whitespace is not allowed.


See Also:   SolrPluginUtils.parseFieldBoosts



parseQueryStrings
public static List<Query> parseQueryStrings(SolrQueryRequest req, String[] queries) throws ParseException(Code)
Turns an array of query strings into a List of Query objects. null if no queries are generated



partialEscape
public static CharSequence partialEscape(CharSequence s)(Code)
Escapes all special characters except '"', '-', and '+'
See Also:   QueryParser.escape



setDefaults
public static void setDefaults(SolrQueryRequest req, SolrParams defaults)(Code)
Set defaults on a SolrQueryRequest. RequestHandlers can use this method to ensure their defaults are visible to other components such as the response writer



setDefaults
public static void setDefaults(SolrQueryRequest req, SolrParams defaults, SolrParams appends, SolrParams invariants)(Code)
Set default-ish params on a SolrQueryRequest. RequestHandlers can use this method to ensure their defaults and overrides are visible to other components such as the response writer
Parameters:
  req - The request whose params we are interested i
Parameters:
  defaults - values to be used if no values are specified in the request params
Parameters:
  appends - values to be appended to those from the request (or defaults) when dealing with multi-val params, or treated as another layer of defaults for singl-val params.
Parameters:
  invariants - values which will be used instead of any request, or default values, regardless of context.



setMinShouldMatch
public static void setMinShouldMatch(BooleanQuery q, String spec)(Code)
Checks the number of optional clauses in the query, and compares it with the specification string to determine the proper value to use.

Details about the specification format can be found here

A few important notes...

  • If the calculations based on the specification determine that no optional clauses are needed, BooleanQuerysetMinMumberShouldMatch will never be called, but the usual rules about BooleanQueries still apply at search time (a BooleanQuery containing no required clauses must still match at least one optional clause)
  • No matter what number the calculation arrives at, BooleanQuery.setMinShouldMatch() will never be called with a value greater then the number of optional clauses (or less then 1)

:TODO: should optimize the case where number is same as clauses to just make them all "required"




setReturnFields
public static int setReturnFields(SolrQueryRequest req, SolrQueryResponse res)(Code)
Assumes the standard query param of "fl" to specify the return fields
See Also:   SolrPluginUtils.setReturnFields(String,SolrQueryResponse)



setReturnFields
public static int setReturnFields(String fl, SolrQueryResponse res)(Code)
Given a space seperated list of field names, sets the field list on the SolrQueryResponse. bitfield of SolrIndexSearcher flags that need to be set



split
public static String[] split(String value)(Code)
Split a value that may contain a comma, space of bar separated list.



stripUnbalancedQuotes
public static CharSequence stripUnbalancedQuotes(CharSequence s)(Code)
Returns it's input if there is an even (ie: balanced) number of '"' characters -- otherwise returns a String in which all '"' characters are striped out.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.