Help querying for keywords and address?

Hi everybody,

I'm new to ES and trying to figure out the correct way to query the
following data:

{
"Address": {
"StreetNumber": "200 Cherry St.",
"Country": "United States",
"City": "New York",
"Neighborhood": null,
"CountryCode": "US",
"State": "New York"
},
"Geo": {
"Longitude": "4.63315496497437",
"Latitude": "-74.071588516908"
},
"Name": "Plain Text Name",
"PhoneNumbers": [
{
"PhoneType": 0,
"Number": "(1) (713) 6094792"
}
],
"Topics": [
"Galer\u00edas de Arte",
"A"
],

"About": "This is some test about a place"
"_id": "BIG-LONG-ID-STRING"
}

I want to be able to do a text search against the Name, About, and Topics fields. In some cases I also want to do a match against City, State, and Country. In others I'm going to want to do a geo search with a selected distance for matches.

Can anyone offer some help with this at least point me in the right direction to get started? It seems like all of the online examples are reference implementations of single-uses of different features and I'm having trouble understanding how to use them together.

Thanks!

Matt

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hello Matt,

I'm not sure exactly what you're looking for, but I'm trying to give you
some links that might help you get started.

If you need to combine different queries, like "I need it to be in US, it
would be nice to be in New York, but shouldn't have a certain phone number
type", you should look at bool queries:
http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html

For your queries to work, it's important to define your mapping in a way
that matches your use-case. More about mappings here (and on the right-side
links to specific information):
http://www.elasticsearch.org/guide/reference/mapping/

For example, if you want only exact matches for Address.City, you need to
add index: not_analyzed to that particular field. Something like:

Another thing you might want to look for is how you put your mapping for
arrays. With the default "dynamic" type, if you look for a phone type 1
that contains 123, it will match a doc that contains these two in separate
elements of the array, like

"PhoneNumbers": [
{
"PhoneType": 1,
"Number": "456"
},
{
"PhoneType": 0,
"Number": "123"
}
]

If you don't want that, you have to look at nested type instead of dynamic:
http://www.elasticsearch.org/guide/reference/mapping/nested-type.html

And query it via the Nested query:
http://www.elasticsearch.org/guide/reference/query-dsl/nested-query.html

That's all the stuff that seems to me relevant for your use-case. But if
you need more, don't hesitate to ask. Usually, at least someone here knows
the answer :slight_smile:

Best regards,
Radu

http://sematext.com/ -- ElasticSearch -- Solr -- Lucene

On Fri, Feb 8, 2013 at 9:14 PM, Matt Walters mattwalters5@gmail.com wrote:

Hi everybody,

I'm new to ES and trying to figure out the correct way to query the
following data:

{
"Address": {
"StreetNumber": "200 Cherry St.",
"Country": "United States",
"City": "New York",
"Neighborhood": null,
"CountryCode": "US",
"State": "New York"
},
"Geo": {
"Longitude": "4.63315496497437",
"Latitude": "-74.071588516908"
},
"Name": "Plain Text Name",
"PhoneNumbers": [
{
"PhoneType": 0,
"Number": "(1) (713) 6094792"
}
],
"Topics": [
"Galer\u00edas de Arte",
"A"
],

"About": "This is some test about a place"
"_id": "BIG-LONG-ID-STRING"
}

I want to be able to do a text search against the Name, About, and Topics fields. In some cases I also want to do a match against City, State, and Country. In others I'm going to want to do a geo search with a selected distance for matches.

Can anyone offer some help with this at least point me in the right direction to get started? It seems like all of the online examples are reference implementations of single-uses of different features and I'm having trouble understanding how to use them together.

Thanks!

Matt

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.