配置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的所有满足条件的楼盘:

http://192.168.181.140:8487/solr/loupan/select/?q=city_id:11&fq={!geofilt pt=31.254982,121.47501 sfield=latlng d=5}

查找满足指定距离的结果集,并按照距离由近到远排序

http://192.168.181.140:8487/solr/loupan/select/?q=*:*&fq={!geofilt}&pt=31.2367,121.501&sfield=latlng&d=5&sort=geodist()+asc

参考:

(转载)solr实现满足指定距离范围条件的搜索的更多相关文章

  1. lucene多条件查询”搜索—BooleanQuery

    /** * “多条件查询”搜索—BooleanQuery * BooleanQuery也是实际开发过程中经常使用的一种Query. * 它其实是一个组合的Query,在使用时可以把各种Query对象添 ...

  2. 如何使用Marketing Cloud的扩展字段作为搜索条件进行搜索

    需求:我在Marketing Cloud的contact模型上用custom field这个应用创建了一个Extension field,名称为微信ID. 现在客户的需求是使用这个字段作为过滤条件进行 ...

  3. [转载] Solr使用入门指南

    转载自http://blog.csdn.net/liuzhenwen/article/details/4060922 由于搜索引擎功能在门户社区中对提高用户体验有着重要的作用,在门户社区中涉及大量需要 ...

  4. 【solr】之solr界面查询返回距离并排序

    使用solr界面查询 {!geofilt}距离函数 star:[4 TO 5]星级排序 geodist() desc 距离排序 pt :31.221717,121.580891 sfield:loca ...

  5. Solr局部或指定字段更新之set用法

    solr wiki文档也有        http://yonik.com/solr/atomic-updates/         java code   public static void up ...

  6. 一个ROS的服务,使机器人向前移动指定距离

    源代码有点长,放文末链接里了. 服务描述及代码现在的服务是:请求时携带要前进的距离,然后底盘前进相应距离.代码如下,改动很小: #!/usr/bin/env python import rospyfr ...

  7. NSPredicate类,指定过滤器的条件---董鑫

    /* 比较和逻辑运算符 就像前面的例子中使用了==操作符,NSPredicate还支持>, >=, <, <=, !=, <>,还支持AND, OR, NOT(或写 ...

  8. (转载)solr时区问题解决方案

    solr默认的使用的是utc格林尼治时间,与我们的GMT+8相差8个小时,网上好多解决办法是在自己应用中的时间上加8个小时和减8个小时做变换:或者不用date类型,改为long. 个人感觉这两个办法都 ...

  9. Linq→join中指定多个条件

    还是习惯先撸一段SQL * FROM User_Pic P AND P.Guid = R.UserPicGuid ORDER BY PicSize DESC 然后发现Linq中的join不能多条件.. ...

随机推荐

  1. 【整体二分】【P3527】 [POI2011]MET-Meteors

    Description 有 n 个国家,总共占有一个环,环被分成了 m 段,已知有 k 次流星雨会落在这个环上的一些位置.再给出每个国家目标收集多少流星,对每个国家求出第几次流星雨后可以满足这个国家的 ...

  2. 《剑指offer》面试题45 圆圈中最后剩下的数字(Java版本)

    引言 这道题网上的讲解都是直接抄书,没意思,所以想自己写一写,补充一下,便于自己理解.另外,大家都忽略了经典解法,虽然这种解法效率不及第二种,但是我觉得在项目当中阅读性其实很重要,牺牲一点点效率保证代 ...

  3. 终于把5GB的Cygwin安装完成了

    From:http://www.cnblogs.com/killerlegend/p/3904478.html Author:KillerLegend Date:2014.8.11 首先,只想说一句, ...

  4. 穷竭搜索: POJ 2718 Smallest Difference

    题目:http://poj.org/problem?id=2718 题意: 就是输入N组数据,一组数据为,类似 [1  4  5  6  8  9]这样在0~9之间升序输入的数据,然后从这些数据中切一 ...

  5. 关于mysql 5.7版本“报[Err] 1093 - You can't specify target table 'XXX' for update in FROM clause”错误的bug

    不同于oracle和sqlserver,mysql并不支持在更新某个表的数据时又查询了它,而查询的数据又做了更新的条件,因此我们需要使用如下的语句绕过: , notice_code ) a) ; 本地 ...

  6. Linux下压缩文件-1

    tar负责打包,gzip负责压缩 tar-c: 建立压缩档案-x:解压-t:查看内容-r:向压缩归档文件末尾追加文件-u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的 ...

  7. [整理]Node入门 » 一本全面的Node.js教程 - Demo实践所遇到的问题

    花了一个上午看完[转载]Node入门 » 一本全面的Node.js教程 根据里面的Demo自己手动实现过程中还是遇到了些问题,特整理在此. <1>.由于node.msi安装包已经自动添加了 ...

  8. 使用Console命令调试JS

    一.console 的对象常用的方法 1.console.log(object[, object, ...])使用频率最高的一条语句:向控制台输出一条消息.支持 C 语言 printf 式的格式化输出 ...

  9. 解决组合排列问题 A (m ,n) m>=n

    转载自http://blog.csdn.net/sunyujia/article/details/4124011 从n个不同元素中任取m(m≤n)个元素,按照一定的顺序排列起来,叫做从n个不同元素中取 ...

  10. jquery ajax complete 方法

    jquery ajax var ajaxTimeoutTest = $.ajax({ url:'',  //请求的URL timeout : 1000, //超时时间设置,单位毫秒 type : 'g ...