配置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. 支付宝当面付功能demo运行解读

    下载java版本的sdk的demo: 然后拷入idea中: 准备工作: (1)验签工具下载:蚂蚁金服上面下载: https://openclub.alipay.com/read.php?tid=955 ...

  2. springboot中如何添加第三方的jar包或者说如何配置本地jar

    首先推荐博客: spring-boot-maven-plugin 安装本地jar 包 http://www.cnblogs.com/acm-bingzi/p/mavenSpringBootPlugin ...

  3. day1 java基础语法

    一.关键字:java关键字有:abstract boolean break byte case catch char class const continue default do double el ...

  4. MVVM模式原则

    1.MVVM简介 这个模式的核心是ViewModel,它是一种特殊的model类型,用于表示程序的UI状态.它包含描述每个UI控件的状态的属性.例如,文本输入域的当前文本,或者一个特定按钮是否可用.它 ...

  5. 基于 Cocos2d-x-lua 的游戏开发框架 Dorothy 简介

    基于 Cocos2d-x-lua 的游戏开发框架 Dorothy 简介 概述 Dorothy 是一个在 Cocos2d-x-lua 基础上发展起来的分支, 它去掉 Cocos2d-x-lua 那些过多 ...

  6. zookeeper系列之:独立模式部署zookeeper服务

    一.简述 独立模式是部署zookeeper服务的三种模式中最简单和最基础的模式,只需一台机器即可,独立模式仅适用于学习,开发和生产都不建议使用独立模式.本文介绍以独立模式部署zookeeper服务器的 ...

  7. Windows系统环境下Solr之Java实战(一)搭建solr服务器并配置IK分词

    搭建solr服务器 1.下载地址:http://archive.apache.org/dist/lucene/solr/ 2.将D:\JavaWeb\Solr\solr-6.2.0\server\so ...

  8. JS代码判断浏览器版本,支持IE6,IE7,IE8,IE9!三种方法!

    web开发的时候有时候会用到JS检测IE的版本,下面是检测Microsoft Internet Explorer版本的三种代码! 方法一: <script type="text/jav ...

  9. win7下设置挂载Linux服务器nfs共享的数据 -- 转

    最近学习NFS文件系统的使用,Ubuntu上配置好了,想和Win7共享数据,所以网上搜到了这篇文章.借花献佛,跟大家共享一下: http://www.2cto.com/os/201207/139132 ...

  10. Sql Server 逻辑文件 '' 不是数据库 '' 的一部分。请使用 RESTORE FILELISTONLY 来列出逻辑文件名。

    当使用语句还原数据库时,报如下错误: 消息 3234,级别 16,状态 2,第 29 行逻辑文件 'LenborMealOrder_Base_2017' 不是数据库 'Members_01' 的一部分 ...