lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JKnight JKnight <beukni...@gmail.com>
Subject Solr - Group search result
Date Tue, 22 Dec 2009 11:03:49 GMT
Dear all,

I have document doc.xml

<add><doc>
  <field name="id">3</field>
  <field name="name">Love you love me</field>
</doc>
<doc>
  <field name="id">2</field>
  <field name="name">Love story</field>
</doc>
<doc>
  <field name="id">3</field>
  <field name="name">How deep is your love?</field>
</doc>
<doc>
  <field name="id">4</field>
  <field name="name">I love you</field>
</doc>
<doc>
  <field name="id">5</field>
  <field name="name">How deep is your love?</field>
</doc>
<doc>
  <field name="id">6</field>
  <field name="name">Love story</field>
</doc>
</add>

and in schema.xml, I add two line
<field name="name_exact" type="string" indexed="true" stored="false"/>
<copyField source="name" dest="name_exact"/>

After post doc.xml to solr server and run query
http://localhost:8983/solr/select/?wt=json&indent=on&q=love%20you&fl=name&facet=true&facet.field=name_exact

I see the response:
{
 "responseHeader":{
  "status":0,
  "QTime":4,
  "params":{
    "facet":"true",
    "fl":"name",
    "indent":"on",
    "q":"love you",
    "facet.field":"name_exact",
    "wt":"json"}},
 "response":{"numFound":5,"start":0,"docs":[
    {
     "name":"I love you"},
    {
     "name":"Love story"},
    {
     "name":"Love story"},
    {
     "name":"How deep is your love?"},
    {
     "name":"How deep is your love?"}]
 },
 "facet_counts":{
  "facet_queries":{},
  "facet_fields":{
    "name_exact":[
     "How deep is your love?",2,
     "Love story",2,
     "I love you",1,
     "Love you love me",0,
     "Quyen day ne",0,
     "day ne",0]},
  "facet_dates":{}}}

And I have a question. How can I group search result? With my data, I want
to group by "name" field and see only 3 record
    {
     "name":"I love you"},
    {
     "name":"Love story"},
    {
     "name":"How deep is your love?"}

Could you help me?

Thank a lot for support.

-- 
Best regards,
JKnight

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message