配置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. MySQL 第八篇:ORM框架SQLAlchemy

    一 介绍 SQLAlchemy是Python编程语言下的一款ORM框架,该框架建立在数据库API之上,使用关系对象映射进行数据库操作,简言之便是:将对象转换成SQL,然后使用数据API执行SQL并获取 ...

  2. flask-migrate库的使用

    在使用flask-SQLAlchemy库的时候,经常苦恼于该库的creat_all()方法不能对项目中的新建库进行修改,drop_all()又会对数据进行删除,这非常的不方便,万幸,Flask-SQL ...

  3. unity脚本封装成dll

    先申明一下这样做是有需要的.当我们需要把脚本提供给第三方使用,而又不希望对方看到具体的实现过程,这时候就需要将代码封装编译成dll文件,供第三方调用.或是多个项目都要用到同一个模块或同样的功能,则可以 ...

  4. P4394 [BOI2008]Elect 选举

    P4394 [BOI2008]Elect 选举 题目描述 N个政党要组成一个联合内阁,每个党都有自己的席位数. 现在希望你找出一种方案,你选中的党的席位数要大于总数的一半,并且联合内阁的席位数越多越好 ...

  5. RabbitMQ基础介绍

    非原创,仅作为个人的学习资料,转自 anzhsoft http://blog.csdn.net/anzhsoft/article/details/19563091, 1. 历史 RabbitMQ是一个 ...

  6. HTTP 错误 500.19 请求的页面的相关配置数据无效 解决办法

    "HTTP 错误 500.19 请求的页面的相关配置数据无效" 解决办法   HTTP 错误 500.19 - Internal Server Error无法访问请求的页面,因为该 ...

  7. H264编码profile & level控制

    背景知识 先科普一下profile&level.(这里讨论最常用的H264) H.264有四种画质级别,分别是baseline, extended, main, high:  1.Baseli ...

  8. 让网页的title动起来

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  9. XML学习(1)

    什么是XML? XML是可拓展标记语言,类似HTML,它的设计宗旨是为了传输数据,而不是像HTML那样显示数据.XML标签没有被预定义,需要用户自定义标签. xml文档必须包含根元素,它是其他所有元素 ...

  10. Java写的数据库连接池

    原文地址: http://lgscofield.iteye.com/blog/1820521 import java.sql.*; import java.util.Enumeration; impo ...