Reputation: 592
I have a Solr index which contains objects (in practise, records of historic pictures of WW1 servicemen, and also oral history audio recordings) which all have references to named agents. The index also contains simple records of all the agents, and the object records contain the IDs of these (but note that the agent records do not contain the object IDs).
Typical object record extract:
"agentReference": [
"agent-571916"
],
I'm afraid I am fairly new to Solr so I don't know if this is a simple (indeed obvious) question, or more complex. What I would like to get is a list of the agent IDs that have multiple objects associated with them, and the IDs of those objects. So something like ...
agent-571916 : object-12345 object-23456 object-98765
Apologies if this is an ignorant question. I could write a script to loop through all agent IDs and call a query to return objects for each, but I would still then have to match them up with unique counts, and for the dataset in question it's likely to be about 16,000 agents.
Edit: I should have added that I can of course facet by agentReference and apply facet.mincount=2 which gets me close, but it's getting back the object IDs against each of those agents that is what I need.
<int name="agent-2876">5</int>
<int name="agent-443281">5</int>
<int name="agent-239379">4</int>
<int name="agent-257708">4</int>
<int name="agent-26269">4</int>
<int name="agent-279277">4</int>
Upvotes: 0
Views: 198
Reputation: 1114
Json faceting should solve your problem [1] .
{
Agents: {
type: terms,
field: agentReference,
mincount: 1,
facet: {
Products: {
type: terms,
field: id,
mincount: 1
}
}
}}
It is available starting from Solr 5 and it is quite easy to use. You can complicate your stats on the results as you like according the documentation.
[1] http://yonik.com/json-facet-api/
Upvotes: 1