(转载)solr实现满足指定距离范围条件的搜索
配置schema.xml
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="aifang-loupan" version="1.1">
<types>
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="integer" class="solr.IntField" omitNorms="true"/> <fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/> <fieldType name="tint" class="solr.TrieIntField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/> <fieldType name="sint" class="solr.SortableIntField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="slong" class="solr.SortableLongField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="sfloat" class="solr.SortableFloatField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="sdouble" class="solr.SortableDoubleField" sortMissingLast="true" omitNorms="true"/> <fieldType name="date" class="solr.TrieDateField" omitNorms="true" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>
<fieldtype name="ignored" stored="false" indexed="false" class="solr.StrField"/>
<fieldtype name="location" class="solr.LatLonType" subFieldSuffix="_d"/>
<fieldType name="text" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType> </types> <fields>
<field name="loupan_id" type="integer" indexed="true" stored="true" required="true"/>
<field name="city_id" type="integer" indexed="true" stored="false"/>
<field name="loupan_name" type="text" indexed="true" stored="false"/>
<field name="loupan_pinyin" type="string" indexed="true" stored="false"/>
<field name="alias_name" type="text" indexed="true" stored="false"/>
<field name="former_name" type="text" indexed="true" stored="false"/>
<field name="region_title" type="text" indexed="true" stored="false" />
<field name="region_id" type="int" indexed="true" stored="false"/>
<field name="sub_region_title" type="text" indexed="true" stored="false"/>
<field name="sub_region_id" type="int" indexed="true" stored="false"/>
<field name="regions_string" type="string" indexed="true" stored="false" multiValued="true"/>
<field name="address" type="text" indexed="true" stored="false"/>
<field name="proxy_address" type="text" indexed="true" stored="false"/>
<field name="chanquan" type="text" indexed="true" stored="false"/>
<field name="build_type" type="text" indexed="true" stored="false" multiValued="true"/>
<field name="property_type" type="text" indexed="true" stored="false" multiValued="true"/>
<field name="fitment_type" type="text" indexed="true" stored="false" multiValued="true"/>
<field name="search_kw" type="text" indexed="true" multiValued="true" stored="false" />
<field name="investor" type="text" indexed="true" stored="false"/>
<field name="company" type="text" indexed="true" stored="false"/>
<field name="loop_line" type="text" indexed="true" stored="false" />
<field name="status_sale" type="integer" indexed="true" stored="false"/>
<field name="status_disp" type="integer" indexed="true" stored="false"/>
<field name="search_sale" type="integer" indexed="true" stored="false" multiValued="true"/>
<field name="jiaofang_date" type="sint" indexed="true" stored="false"/>
<field name="kaipan_date" type="sint" indexed="true" stored="false"/>
<field name="price" type="sint" index="true" stored="false"/>
<field name="baidu_lat" type="sfloat" indexed="true" stored="false"/>
<field name="baidu_lng" type="sfloat" indexed="true" stored="false"/>
<field name="lat" type="sfloat" indexed="true" stored="false"/>
<field name="lng" type="sfloat" indexed="true" stored="false"/>
<field name="metro_subway_id" type="integer" indexed="true" stored="false" multiValued="true" />
<field name="metro_station_id" type="integer" indexed="true" stored="false" multiValued="true" />
<field name="metro_enabled" type="integer" indexed="true" stored="false"/>
<field name="metro_info" type="text" indexed="true" stored="false" multiValued="true" />
<field name="loop_line_id" type="integer" indexed="true" stored="false"/>
<field name="property_type_id" type="integer" indexed="true" stored="false" multiValued="true"/>
<field name="build_type_id" type="integer" indexed="true" stored="false" multiValued="true"/>
<field name="fitment_type_id" type="integer" indexed="true" stored="false" multiValued="true"/>
<field name="developer_id" type="integer" indexed="true" stored="false" multiValued="true"/>
<field name="developer_title" type="string" indexed="true" stored="false"/>
<field name="business_id" type="integer" indexed="true" stored="false"/>
<field name="business_title" type="string" indexed="true" stored="false"/>
<field name="loupan_extend_type" type="sint" indexed="true" stored="false" multiValued="true"/>
<field name="trip_fitment_style" type="text" indexed="true" stored="false" />
<field name="trip_feature_recommend" type="text" indexed="true" stored="false" multiValued="true" />
<field name="trip_spot" type="text" indexed="true" stored="false" multiValued="true" />
<field name="trip_transport" type="text" indexed="true" stored="false" multiValued="true" />
<field name="trip_scenic_region" type="text" indexed="true" stored="false" multiValued="true" />
<field name="trip_property_service" type="text" indexed="true" stored="false" multiValued="true" />
<field name="trip_scenic_spot" type="text" indexed="true" stored="false"/>
<field name="trip_created" type="sint" indexed="true" stored="false" />
<field name="is_trip" type="int" indexed="true" stored="false" />
<field name="level" type="sint" indexed="true" stored="false"/>
<field name="loupan_pv_day" type="sint" indexed="true" stored="false" />
<field name="operator_ids" type="integer" indexed="true" stored="false" multiValued="true"/>
<field name="operator_names" type="string" indexed="true" stored="false" multiValued="true"/>
<dynamicField name="*_grade" type="sint" indexed="true" stored="false" />
<field name="updated" type="sint" indexed="true" stored="false" />
<field name="news_id" type="int" indexed="true" stored="false" />
<field name="news_update" type="sint" indexed="true" stored="false" />
<field name="rank" type="sfloat" indexed="true" stored="false" />
<field name="sale_order" type="sint" indexed="true" stored="false" />
<field name="vip_order" type="string" indexed="true" stored="false" />
<field name="kaipan_order" type="sint" indexed="true" stored="false"/>
<field name="created" type="sint" indexed="true" stored="false" />
<field name="latlng" type="location" indexed="true" />
<dynamicField name="*_d" type="double" indexed="true" stored="true"/>
</fields> <uniqueKey>loupan_id</uniqueKey>
<defaultSearchField>search_kw</defaultSearchField>
<solrQueryParser defaultOperator="AND"/>
</schema>
在提交数据时的格式为:(纬度,经度:以字符串的方式提交给solr)
<field name="store">45.17614,-93.87341</field> <!-- Buffalo store -->
<field name="store">40.7143,-74.006</field> <!-- NYC store -->
<field name="store">37.7752,-122.4232</field> <!-- San Francisco store -->
例如要查寻距离纬度经度(31.254982,121.47501)5km的所有满足条件的楼盘:
查找满足指定距离的结果集,并按照距离由近到远排序
参考:
(转载)solr实现满足指定距离范围条件的搜索的更多相关文章
- lucene多条件查询”搜索—BooleanQuery
/** * “多条件查询”搜索—BooleanQuery * BooleanQuery也是实际开发过程中经常使用的一种Query. * 它其实是一个组合的Query,在使用时可以把各种Query对象添 ...
- 如何使用Marketing Cloud的扩展字段作为搜索条件进行搜索
需求:我在Marketing Cloud的contact模型上用custom field这个应用创建了一个Extension field,名称为微信ID. 现在客户的需求是使用这个字段作为过滤条件进行 ...
- [转载] Solr使用入门指南
转载自http://blog.csdn.net/liuzhenwen/article/details/4060922 由于搜索引擎功能在门户社区中对提高用户体验有着重要的作用,在门户社区中涉及大量需要 ...
- 【solr】之solr界面查询返回距离并排序
使用solr界面查询 {!geofilt}距离函数 star:[4 TO 5]星级排序 geodist() desc 距离排序 pt :31.221717,121.580891 sfield:loca ...
- Solr局部或指定字段更新之set用法
solr wiki文档也有 http://yonik.com/solr/atomic-updates/ java code public static void up ...
- 一个ROS的服务,使机器人向前移动指定距离
源代码有点长,放文末链接里了. 服务描述及代码现在的服务是:请求时携带要前进的距离,然后底盘前进相应距离.代码如下,改动很小: #!/usr/bin/env python import rospyfr ...
- NSPredicate类,指定过滤器的条件---董鑫
/* 比较和逻辑运算符 就像前面的例子中使用了==操作符,NSPredicate还支持>, >=, <, <=, !=, <>,还支持AND, OR, NOT(或写 ...
- (转载)solr时区问题解决方案
solr默认的使用的是utc格林尼治时间,与我们的GMT+8相差8个小时,网上好多解决办法是在自己应用中的时间上加8个小时和减8个小时做变换:或者不用date类型,改为long. 个人感觉这两个办法都 ...
- Linq→join中指定多个条件
还是习惯先撸一段SQL * FROM User_Pic P AND P.Guid = R.UserPicGuid ORDER BY PicSize DESC 然后发现Linq中的join不能多条件.. ...
随机推荐
- C++析构函数的自动调用(用于父类指针指向子类对象,内存泄漏问题)
class A {public:A() { printf("A \n"); }~A() { printf(" ~A \n"); } // 这里不管写不写virt ...
- kubernetes 1.9部署实践
目录 简要说明 环境说明 安装前的约定 配置etcd 生成相关证书 证书类型说明 cfssl配置 证书相关配置 生成ca证书 生成kubernetes证书 生成kubectl证书 生成kube-pro ...
- Integer.parseInt不同jdk源码解析
执行以下代码: System.out.println(Integer.parseInt("-123")); System.out.println(Integer.parseInt( ...
- android listview使用自定义的adapter没有了OnItemClickListener事件解决办法
在使用listview的时用使用自定义的adapter的时候,如果你的item布局中包含有Button,Checkable继承来的所有控件,那么你将无法获取listview的onItemClickLi ...
- 3 Kafka两个版本在Zookeeper的元数据存储
0.8 [consumers, admin, config, controller, brokers, controller_epoch] 这些节点都归于谁管理 consumers: 0.8版本的客户 ...
- bootstrap-switch与angularjs结合使用
bootstrap-switch和angularjs结合使用 由于angularjs的dom操作总是先执行,导致$(input[name="switch"])找不到元素,所以使用d ...
- python字符中加入变量
有时候,我们需要在字符串中加入相应的变量,以下提供了几种字符串加入变量的方法: 1.+ 连字符 name = 'zhangsan' print('my name is '+name) #结果为 my ...
- css实现0.5像素的边框
公司的设计师在做设计图的时候都是以iphone6(宽为750物理像素)为基准进行设计的.iphone6的设备像素比(即css像素与物理像素的比例)是2,所以设计师在设计图画了边框为1px的box的时候 ...
- MYSQL 在当前时间加上或减去一个时间段
update user set time1=now(),time2=date_add(NOW(), interval 1 MONTH) where id=1; date_add() 增加date_su ...
- 【CodeForces】906 D. Power Tower 扩展欧拉定理
[题目]D. Power Tower [题意]给定长度为n的正整数序列和模数m,q次询问区间[l,r]累乘幂%m的答案.n,q<=10^5,m,ai<=10^9. [算法]扩展欧拉定理 [ ...