- 浏览: 102874 次
- 性别:
- 来自: 东营
文章分类
最新评论
-
ln987604356:
```说明都没得 看锤子
弹出 div jquery.jmpopups-0.5.1.js -
yanshaozhi:
snowolf 写道工作中的收获,远远不只是工资,但往往首先需 ...
完全成为了一个职员 -
snowolf:
工作中的收获,远远不只是工资,但往往首先需要考虑工资。因为你要 ...
完全成为了一个职员 -
onex:
相比于其他的那两位,我觉得你很不错。很欣赏你。 你继续抱着学习 ...
完全成为了一个职员
12.5.4. CompassQuery and CompassQueryBuilder Compass::Core comes with the CompassQueryBuilder interface, which provides programmatic API for building a query. The query builder creates a CompassQuery which can than be used to add sorting and executing the query. Working with objects Compass - Java Search Engine 108Using the CompassQueryBuilder, simple queries can be created (i.e. eq, between, prefix, fuzzy), and more complex query builders can be created as well (such as a boolean query, multi-phrase, and query string). The following code shows how to use a query string query builder and using the CompassQuery add sorting to the result. CompassHits hits = session.createQueryBuilder() .queryString("+name:jack +familyName:london") .setAnalyzer("an1") // use a different analyzer .toQuery() .addSort("familyName", CompassQuery.SortPropertyType.STRING) .addSort("birthdate", CompassQuery.SortPropertyType.INT) .hits(); Another example for building a query that requires the name to be jack, and the familyName not to be london: CompassQueryBuilder queryBuilder = session.createQueryBuilder(); CompassHits hits = queryBuilder.bool() .addMust( queryBuilder.term("name", "jack") ) .addMustNot( queryBuilder.term("familyName", "london") ) .toQuery() .addSort("familyName", CompassQuery.SortPropertyType.STRING) .addSort("birthdate", CompassQuery.SortPropertyType.INT) .hits(); CompassQuery can also be created using the Compass instance, without the need to construct a CompassSession. They can then stored and used safely by multiple sessions (in a multi threaded environment) by attaching them to the current session using CompassQuery#attach(CompssSession) API. Note that sorted resource properties / meta-data must be stored and not_analyzed. Also sorting requires more memory to keep sorting properties available. For numeric types, each property sorted requires four bytes to be cached for each resource in the index. For String types, each unique term needs to be cached. When a query is built, most of the queries can accept an Object as a parameter, and the name part can be more than just a simple string value of the meta-data / resource-property. If we take the following mapping for example: <class name="eg.A" alias="a"> <id name="id" /> <property name="familyName"> <meta-data>family-name</meta-data> </property> <property name="date"> <meta-data converter-param="YYYYMMDD">date-sem</meta-data> </property> </class> The mapping defines a simple class mapping, with a simple string property called familyName and a date property called date. With the CompassQueryBuilder, most of the queries can directly work with either level of the mappings. Here are some samples: CompassQueryBuilder queryBuilder = session.createQueryBuilder(); // The following search will result in matching "london" against "familyName" CompassHits hits = queryBuilder.term("a.familyName.family-name", "london").hits(); // The following search will use the class property meta-data id, which in this case // is the first one (family-name). If there was another meta-data with the family-name value, // the internal meta-data that is created will be used ($/a/familyName). CompassHits hits = queryBuilder.term("a.familyName", "london").hits(); // Here, we provide the Date object as a parameter, the query builder will use the Working with objects Framework (2.2.0 GA)// converter framework to convert the value (and use the given parameter) CompassHits hits = queryBuilder.term("a.date.date-sem", new Date()).hits(); // Remmember, that the alias constraint will not be added automatically, so // the following query will cause only family-name with the value "london" of alias "a" CompassHits hits = queryBuilder.bool() .addMust( queryBuilder.alias("a") ) .addMust( queryBuilder.term("a.familyName", "london") ) .toQuery().hits(); When using query strings and query parsers, Compass enhances Lucene query parser to support custom formats (for dates and numbers, for example) as well as support dot path notation. The query: a.familyname.family-name:london will result in a query matching on familyName to london as well as wrapping the query with one that will only match the a alias.
发表评论
-
Red5 的一点点感悟
2011-07-17 21:09 895最近一个项目需要用到客户端的录音功能,大概的方案就是Flex ... -
JFreechart 绘制闭合曲线
2011-06-28 14:25 798在网上搜了不少,但实现总是感觉有点难受,无奈还是要看API ... -
短信mao编码问题
2011-06-16 23:51 796最近一个项目要用到短信mao,乱码问题折腾了挺久,由于项目都是 ... -
itext 学习地址
2011-06-08 14:23 637http://www.roseindia.net/java/i ... -
Nutz 例子,从mvc ioc 到数据插入
2011-04-18 13:06 735create table rb_user( u ... -
设计模式
2010-03-13 14:16 584http://www.riabook.cn/doc/desig ... -
Lucene in Action 下载(英文)
2009-12-01 18:49 621防止丢了,就放这里了,顺便共享下! -
NSIS 设置系统变量
2009-07-01 11:04 1151;set env WriteRegExpandStr HK ... -
flex box 组件间隔
2009-06-25 12:23 882VBox 属性 verticalGap="0&quo ... -
java动态代理
2009-06-18 16:08 667被代理的对象 厂家 代理对象 商家 publ ... -
20 very useful Java code snippets for Java Develop
2009-05-20 11:07 11561. Converting Strings to int an ... -
git 设置 用户名和信箱
2009-05-14 11:09 19390Guides: Tell git your user name ... -
ubuntu install java
2009-05-04 11:33 818http://www.cyberciti.biz/faq/ho ... -
java png gif bmp to jpg
2009-04-23 11:17 1921File file = new File("d: ... -
flex 组合键实现
2009-04-01 13:25 3050可行: var ctrl:Boolean=event.ct ... -
eclipse 不能启动
2009-03-11 09:19 821eclipse.ini的配置如下: -showsplash ... -
hibernate 主键生成方式
2009-01-17 13:47 651对于SQLServer数据库在使用中如果将表的主键字段id设为 ... -
久违的jdbc样板代码
2009-01-17 11:52 783public class DB { private S ... -
InputSteam to OutputStream
2008-10-23 16:00 955InputStream in = node.getProper ... -
sling中配置servlet是否被访问到
2008-10-21 10:05 776@scr.property name="sling. ...
相关推荐
mongodb-windows安装包: mongodb-compass-1.31.2-win32-x64.msi 打开直接安装
MongoDB的讲义,资源包。与大数据hadoop学习相关,包含快速入手MongoDB和MongoDB集群安全两个部分,以及mongoDB的可视化工具zip包MongoDB-compass
mongodb-compass-community-1.21.2-win32-x64.exe mongodb-compass-community-1.21.2-win32-x64.exe mongodb-compass-community-1.21.2-win32-x64.exe mongodb-compass-community-1.21.2-win32-x64.exe
mongodb-compass-community-1.18.0-win32-x64.msi
mongodb-compass-1.42.1-win32-x64.exe 数据库构建工具
mongodb官方客户端可视化工具compass-1.26.1-win32-x64
安装mongodb时会自动联网下载mongodb-compass,但是网速非常慢,有些人甚至等了一晚上都没有结果。可以选择在安装mongodb时先不安装mongodb-compass,事后单独安装。
MongoDB Compass是数据库MongoDB下的一款可视化操作工具,可以帮助我们更轻松的创建和管理数据库。
mongodb-compass-1.28.4-darwin-x64.dmg
mongoDB Compass 以及api-ms-win-crt-runtimel1-1-0.dll文件
mongodb-compass-community-1.16.3-win32-x64.exe
mongodb-compass-community-1.13.0-beta.4-win32-x64,官方无法下载的可以来这里下载。
mongodb-compass-community-1.16.3-win32-x64.exe 可移步百度网盘:链接: https://pan.baidu.com/s/1RcffFh0CYLSrN9F0FXie9Q 提取码: g53s
最新版mongodb-compass-1.16.3-win32-x64
Compass_Setup_2010-06-25_16-11.rar 用于GPS数据处理软件
COMPASS5000基本操作手册-PK.doc
mongodb-compass-1.20.5-win32-x64工具,连接mongodb工具。官方下载慢,现提交一下。
mongodb-compass-1.40.4-win32-x64安装程序
mongodb-compass-1.31.3-win32-x64.zip