Returning count on field matches (on a query across all fields)

Given an example document mapping:

{
"users": {
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"address": {
"type": "string"
}
}
}
}

Now if we index several documents in this mapping, and then do a query
across all fields (like a free text query):

{
"query": {
"query_string": {
"query": "A*"
}
}

Now each hit in this query would match against some field in a given
document (say it matches first_name on 50 occasions, last_name on 30
occasions, address on 60 occasions).

Is there a way in ES where I could get the above kind of result set ? Can
you achieve something like this using facets?

I was not able to figure out a way to return the count on field matches.
Any help would be appreciated.

--
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.

AFAIK, the only way to get this information is to parse the score
explanation yourself to see which fields were used in the scoring. Each hit
contains its own explanation. Of course, since you have to parse the data
yourself, then you can only aggregate stats on the top k documents.

--
Ivan

On Wed, Oct 30, 2013 at 3:54 PM, Saurabh Daftary sdaftary19@gmail.comwrote:

Given an example document mapping:

{
"users": {
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"address": {
"type": "string"
}
}
}
}

Now if we index several documents in this mapping, and then do a query
across all fields (like a free text query):

{
"query": {
"query_string": {
"query": "A*"
}
}

Now each hit in this query would match against some field in a given
document (say it matches first_name on 50 occasions, last_name on 30
occasions, address on 60 occasions).

Is there a way in ES where I could get the above kind of result set ? Can
you achieve something like this using facets?

I was not able to figure out a way to return the count on field matches.
Any help would be appreciated.

--
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.

Thanks for your inputs Ivan.I did figure out a way.Kind of a hack
though.You could request a facet query/filter for each field in the
request.Something like:

facets": {
"last_name": {
"query": {
"query_string": {
"query": "lastName: San*"
}
}
},
"first_name": {
"query": {
"query_string": {
"query": "firstName: San*"
}
}
}
}

Assuming firstName and lastName are your two fields........

On Wednesday, 30 October 2013 18:54:16 UTC-4, Saurabh Daftary wrote:

Given an example document mapping:

{
"users": {
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"address": {
"type": "string"
}
}
}
}

Now if we index several documents in this mapping, and then do a query
across all fields (like a free text query):

{
"query": {
"query_string": {
"query": "A*"
}
}

Now each hit in this query would match against some field in a given
document (say it matches first_name on 50 occasions, last_name on 30
occasions, address on 60 occasions).

Is there a way in ES where I could get the above kind of result set ? Can
you achieve something like this using facets?

I was not able to figure out a way to return the count on field matches.
Any help would be appreciated.

--
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.