(转载)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不能多条件.. ...
随机推荐
- winscp以命令行方式同步服务器数据到PC机磁盘上
目前服务器上每日会产生备份文件,需要使用winscp工具把备份同步到本地PC机硬盘上.平时都是图形界面用鼠标点击方式来同步的,效率低下,因此编写了winscp自动同步脚本,并加入到计划任务中定时自动运 ...
- GO_05:GO语言基础map与函数
1. map 1. 类似其它语言中的哈希表活着字典,以 key-value 形式存储数据 2. key 必须是支持 == 或 != 比较运算的类型,不可以是函数.map 或 slice 3. map ...
- Tomcat权威指南-读书摘要系列4
4. Tomcat的性能调校 测量Web服务器的性能 测试负载的工具 Apache Benchmark Siege JMeter
- 科学计算三维可视化---TraitsUI(Group对象组织界面)
使用Group对象组织界面 将一组相关的Item对象组织在一起 from traitsui.api import Group from traits.api import HasTraits,Int, ...
- bzoj千题计划109:bzoj1019: [SHOI2008]汉诺塔
http://www.lydsy.com/JudgeOnline/problem.php?id=1019 题目中问步骤数,没说最少 可以大胆猜测移动方案唯一 (真的是唯一但不会证) 设f[i][j] ...
- COGS 栅格网络流
750. 栅格网络流 http://www.cogs.pro/cogs/problem/problem.php?pid=750 ★★☆ 输入文件:flowa.in 输出文件:flowa.out ...
- 数据结构编程实验——chapter9-应用二叉树的基本概念编程
二叉树是树结构中的重要概念,一些特殊的二叉树如满二叉树和完全二叉树由于节点序号的特殊关系,在一些算法中十分常见. 这篇文章将从三个方面介绍有关二叉树的知识点: (1) 普通有序树转化为二叉树. ( ...
- yum安装_yum命令的相关操作
2017年1月11日, 星期三 yum安装的四种方式 一.默认:从国外下载 二.国内:从阿里获取 http://mirrors.aliyun.com 1. cd /etc/yum.repos.d 2 ...
- 实验九 Web安全基础
- 20155307 2016-2017-2 《Java程序设计》第6周学习总结
20155307 2016-2017-2 <Java程序设计>第6周学习总结 教材学习内容总结 串流数据有来源及目的地,衔接两者的是串流对象.如果要将数据从来源取出,可以使用输入串流:如果 ...