Java search for lat/long fields

Thanks David,

When I use this code:

*node* = NodeBuilder.*nodeBuilder*().client(*true*).node();

// We wait now for the yellow (or green) status

*node*.client().admin().cluster().prepareHealth()

    .setWaitForYellowStatus().execute().actionGet();

The second line (with the prepareHealth call) throws exception:

org.elasticsearch.discovery.MasterNotDiscoveredException: waited for [30s]

It works when I use this code:

Client client = *new* TransportClient().addTransportAddress(*new*InetSocketTransportAddress(

    "localhost", 9300));

// We wait now for the yellow (or green) status

client.admin().cluster().prepareHealth()

    .setWaitForYellowStatus().execute().actionGet();



client.admin().indices().prepareCreate("asset_index"

).execute().actionGet();

Regards,

Janusz

On Thursday, January 10, 2013 1:53:00 PM UTC+11, JD wrote:

Hi,

I have a quite a few documents like this that are indexed in elasticsearch
db (attached is just one for an example):

{

"took": 28,

"timed_out": false,

"_shards": {

    "total": 5,

    "successful": 5,

    "failed": 0

},

"hits": {

    "total": 694,

    "max_score": 1,

    "hits": [

        {

            "_index": "asset_index",

            "_type": "Asset",

            "_id": "4",

            "_score": 1,

            "_source": {

                "_id": 4,

                "className": "com.tycoint.eams.mongodb.AssetDB",

                "name": "FCC_SRV02",

                "serialNo": "Service Tag: 5S2HB2S\nExpress Service 

Tag: 12581131348",

                "description": "Meridian Server Node 2 (Dell PowerEdge 

R710)",

                "location": {

                    "latitude": 5,

                    "longitude": 5

                },

                "address": {

                    "countryCode": "AU",

                    "state": "VIC",

                    "city": "Melbourne",

                    "postcode": "",

                    "street": "FCC",

                    "street2": "",

                    "detail": ""

                },

                "properties": {

                    "K1X3X15": "20121109",

                    "K2X1X1": "10.10.10.11",

                    "K1X3X14": "",

                    "K1X3X13": "",

                    "K2X1X2": "",

                    "K1X3X12": "02 8972 5897",

                    "K2X1X3": "FCC",

                    "K2X1X4": "10.0",

                    "K2X1X5": "",

                    "K1X3X16": "1 Year",

                    "K1X3X8": "",

                    "K1X1X1": "FCC",

                    "K1X2X5": "",

                    "K1X2X4": "FCC",

                    "K1X1X2": "PLD-DRG-A-6112",

                    "K1X3X7": "Dell PowerEdge R710",

                    "K1X1X3": "",

                    "K1X3X9": "Current",

                    "K1X2X1": "Server",

                    "K1X3X11": "Zac Cochrane",

                    "K1X3X10": "DELL Aust Pty Ltd",

                    "K1X2X3": "FCC",

                    "K1X2X2": "FCC",

                    "K3X1X4": "",

                    "K3X1X3": "",

                    "K3X1X2": "",

                    "K3X1X1": "",

                    "K1X3X5": "Physical Key: 

YTF2W-KFJ3P-3W447-8K3J4-42VVQ\nVirtual Key: 39C2W-H7QWQ-DBH43-37MJ8-HPD2G",

                    "K1X3X6": "",

                    "K1X3X3": "IM0004-D-0003 Hardware Architectural 

Design Document \nIM0004-D-0004 Peninsula link Device List",

                    "K1X3X4": "IM0004-PLG-SP-I-0036 Dell PowerEdge 

R710",

                    "K1X3X1": "20111109",

                    "K1X3X2": "Meridian Cluster Node2"

                },

                "productId": 4,

                "assetCategoryId": 0

            }

        }

    ]

}

As you can see my location field has two sub fields latitude/longitude
(under _source).

I would like to retrieve all documents with the distance 500m from
location [1, 1] using Java.

I am trying to play with this code:

SearchRequestBuilder srb =
client.prepareSearch("asset_index").setTypes("Asset").setSearchType(SearchType.DEFAULT).setQuery(QueryBuilders.matchAllQuery());

srb.setFilter(FilterBuilders.geoDistanceRangeFilter("filter1").lat(1).lon(1).geoDistance(
GeoDistance.PLANE));

How can I specify the distance 500 m from lat/long[1/1]?

Any suggestions?

Regards,

Janusz

--