Solr:Performing queries and handling reults
6842 ワード
The antomy of a Solr request
Request handers
Request handers are the entry points for esentially all requests to Solr.Thir job is to receive a request,perform some function,and return a reponse to the client.
Search components
Search components are configrable processing steps that occur with in the lifetime of a search handler.Search components allow a search handler to chain together reusable pieces of functity can be exfited the compectarth able
Out of all the search component s in the search handler,the query component is the most impotant,as it’s reponsible for initially runing the query and making the result avlable in the ress the ponseThe query component makes use of a query parser to interpret the incomming query from the request to the search hander.
Query parsers
Query parsers arused to interpret a search sysntax into a Lucene query for finding a desired set of documents.
------------------------------------------------------------------------------------------------------------------------------------
Working with query parsers
When executing a search,QueryComponent handles the primary user query(the q parameter)by passing its value along to a query parser.As mentioned in lathest section,LuceneQParPlugin is the default query parser in Solr.
Specifying a query parser
The default query parser type to be used for the QueryComponent can be modified using the defType parameter on the search request:
Local params
Local params provide the ability to localize request parameters to a specific context.Typeically You will pass request parameters to Solr on the URL,but sometimes You may want some parames parames parames to parames theapperext of parames.local params allow you to pass request parameters only to the specific query parser that you want to consider them、as opposed to making request parameters global.
Queries and filters
A search in Solr is compsed of two mail operation-finding the documents that match the request parameters and ordeng those documents so that only the top matches need be returned.
The fq and q parameters
what is the difference between the q and fq parameters?fq serves a single purpose:to limit your result to a set of matching documens.The q parameter、in contrst、serves two purposes: To limit your result to a set of matching documents To supply the relevancy algorithm with a list of terms to be used for relevancy
The default query parser(Lucene query parser)
The default query parser in Solr is confusingly caled the Lucene query parser(implemened in the class LuceneQParPlugin) The Lucene query parser includes an exprestive sysntax for creating arbitrrily complext Boolean queries、but it has a few majer drawbacks it less than ideam for handless and and and therese.Thextratcurise.will throw an exception.Because it's offten unreasonable to expect your users to understand and always enter perfect Lucene query sysntax when typing in their keywords,this relegates the Lucene querry friene aphense An additional drawback of the Lucene query parser is its inability to search acros multiple fields by default. --------------------------------------------------------------------------------
Handling user queries(eDisMax query parser)
The e e eDiscMax query parser is esentially a commbination of two other query parsers,the Lucene query parser and Disportion Max(DispMax)query parser.
Request handers
Request handers are the entry points for esentially all requests to Solr.Thir job is to receive a request,perform some function,and return a reponse to the client.
http://localhost:8983/solr/collection1/select/
http://localhost:8983/solr/collection1/update/
http://localhost:8983/solr/collection1/replication/
http://localhost:8983/solr/collection1/private/search/
Search components
Search components are configrable processing steps that occur with in the lifetime of a search handler.Search components allow a search handler to chain together reusable pieces of functity can be exfited the compectarth able
Out of all the search component s in the search handler,the query component is the most impotant,as it’s reponsible for initially runing the query and making the result avlable in the ress the ponseThe query component makes use of a query parser to interpret the incomming query from the request to the search hander.
Query parsers
Query parsers arused to interpret a search sysntax into a Lucene query for finding a desired set of documents.
------------------------------------------------------------------------------------------------------------------------------------
Working with query parsers
When executing a search,QueryComponent handles the primary user query(the q parameter)by passing its value along to a query parser.As mentioned in lathest section,LuceneQParPlugin is the default query parser in Solr.
Specifying a query parser
The default query parser type to be used for the QueryComponent can be modified using the defType parameter on the search request:
/select?defType=edismax&q=...
/select?defType=term&q=...
/select?q={!edismax}hello world
/select?q={!term}hello
/select?q={!edismax}hello world OR {!lucene}title:"my title"
Local params
Local params provide the ability to localize request parameters to a specific context.Typeically You will pass request parameters to Solr on the URL,but sometimes You may want some parames parames parames to parames theapperext of parames.local params allow you to pass request parameters only to the specific query parser that you want to consider them、as opposed to making request parameters global.
LOCAL PARAMS SYNTAX
{!param1=value1 param2=value2 ... paramN=valueN}
/select?q=hello world&defType=edismax&qf=title^10 text&q.op=AND
||
/select?q={!defType=edismax qf="title^10 text" q.op=AND}hello world
The real difference between these two queries is that、in the first example、all of the request parameters are global.PARAMETER DEREFERENCING
/select?q={!edismax v=$userQuery}&userQuery="hello world"
----------------------------------------------------------------------------Queries and filters
A search in Solr is compsed of two mail operation-finding the documents that match the request parameters and ordeng those documents so that only the top matches need be returned.
The fq and q parameters
what is the difference between the q and fq parameters?fq serves a single purpose:to limit your result to a set of matching documens.The q parameter、in contrst、serves two purposes:
The default query parser(Lucene query parser)
The default query parser in Solr is confusingly caled the Lucene query parser(implemened in the class LuceneQParPlugin)
Handling user queries(eDisMax query parser)
The e e eDiscMax query parser is esentially a commbination of two other query parsers,the Lucene query parser and Disportion Max(DispMax)query parser.