Solr 查询语法 与solrj笔记

本节实例query schema

 

  <fields>
   <field name="seq" type="string" indexed="true" stored="true" required="true" multiValued="false" /> 
   <field name="senddatetime" type="date" indexed="fase" stored="true" required="true" multiValued="false" /> 
   <field name="keywords" type="string" indexed="true" stored="true" />
   <field name ="mobile" type="string" indexed="true" stored="true"/>
    <field name ="description" type="text_general" indexed="true" stored="true"/>

	<field name="_version_" type="long" indexed="true" stored="true"/>

  </fields>
 

q

The q parameter is normally the main query for the request. See Solr query syntax for more information on different types of queries and syntaxes.

 

query.setQuery("*:*");

query.setQuery("keywords: \"LP kind 199\"");

query.setQuery("*:* AND NOT seq:a4ec88f8-e0d8-4841-8b02-a88b778d3aa6");

query.setQuery("*:* OR -seq:a4ec88f8-e0d8-4841-8b02-a88b778d3aa6");

 

sort

query.addSortField("senddatetime", ORDER.desc);

start

query.setStart(0);

rows

query.setRows(20);

pageDoc and pageScore

fq

"fq" stands for Filter Query.

This parameter can be used to specify a query that can be used to restrict the super set of documents that can be returned, without influencing score. It can be very useful for speeding up complex queries since the queries specified with fq are cached independently from the main query. Caching means the same filter is used again for a later query (i.e. there's a cache hit). See SolrCaching to learn about the caches Solr uses.

 

query.addFilterQuery(" senddatetime:[2012-11-19T00:59:59.999Z TO 2013-03-06T23:59:59.999Z+1YEAR]");

 

query.addFilterQuery(" senddatetime:[NOW-3MONTHS TO NOW]");

 

Caching of filters

fl

 

This parameter can be used to specify a set of fields to return, limiting the amount of information in the response. When returning the results to the client, only fields in this list will be included.

 

query.setFields("keywords description seq");

 

df

df stands for default search field.

 

        query.setQuery("1316779836");
        query.set("df", "mobile");

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值