: Assume I have documents like this: : {"title": "Robert De Niro", "actors": []} : {"title": "ronin", "actors": ["robert de niro", "jean reno"]} : {"title": "casino", "actors": ["robert de niro", "Joe Pesci"]} ... : Now after search for "robert de niro" in both "title" and "Actors", : I will have some matches, but my question is: How can I find out : what "robert de niro" is? Is he "an actor" or a "movie title"?
I would strongly suggest you rethink your problem. asking solr to identify which _field_ your query matched on is something that is, in general, undefinable since a query might be something like "+title:casion actors:(robert rupert)". Even if in your specific case you know that you will always be querying for the same string in all fields, you'll still run into ambiguious cases where a search might match on *both* the title and actors field (eg: imaging searching for "ray" and matching the movie "Ray" in which "Ray Charles" appears as himself in archive footage) Instead, you should really include in your in index a field that *tells* you what each kind of document is -- and then when you get a set of results back, you can look at that field and say "this is a movie", "this is an actor", etc... (you could probably deduce that from your current schema by looking at wether there are any stored values in the "actors" field, but there's no reason not to just add it as an explicit field -- at which point you can also facet on it, etc...) -Hoss