Re: SolrJ Collapsable Query Fails

2011-07-18 Thread Kurt Sultana
Hi,

Thanks for the code, snippet, it was very useful, however, can you please
include a very small description of certain unknown variables such as
'groupedInfo', 'ResultItem', 'searcher', 'fields' and the method
'solrDocumentToResultItem'?

Thanks

On Sat, Jul 16, 2011 at 3:36 PM, Kurt Sultana kurtanat...@gmail.com wrote:

  Thanks for the information. However, I still have one more
  problem. I am
  iterating over the values of the NamedList. I have 2
  values, one
  being 'responseHeader' and the other one being 'grouped'. I
  would like to
  access some information stored within the grouped section,
  which has
  data structured like so:
 
 
 grouped={attr_directory={matches=4,groups=[{groupValue=C:\Users\rvassallo\Desktop\Index,doclist={numFound=2,start=0,docs=[SolrDocument[{attr_meta=[Author,
  kcook, Last-Modified, 2011-03-02T14:14:18Z...
 
  With the 'get(group)' method I am only able to access the
  entire
  '{attr_directory={matches=4,g...' section. Is there some
  functionality which
  allows me to get other data? Something like this for
  instance:
  'get(group.matches)' or maybe
  'get(group.attr_directory.matches)' (which
  will yield the value of 4), or do I need to process the
  String that the
  'get(...)' returns to get what I need?
 
  Thanks :)

 I think accessing the relevant portion in a NamedList is troublesome. I
 suggest you to look at existing codes in solrJ. e.g. How facet info is
 extracted from NamedList.

 I am sending you the piece of code that I used to access grouped info.
 Hopefully It can give you some idea.

  NamedList signature = (NamedList) groupedInfo.get(attr_directory);

if (signature == null) return new ArrayList(0);

matches.append(signature.get(matches));


@SuppressWarnings(unchecked)
ArrayListNamedList groups = (ArrayListNamedList)
 signature.get(groups);

ArrayList resultItems = new ArrayList(groups.size());

StringBuilder builder = new StringBuilder();


for (NamedList res : groups) {

  ResultItem resultItem = null;

  String hash = null;
  Integer found = null;
  for (int i = 0; i  res.size(); i++) {
String n = res.getName(i);

Object o = res.getVal(i);

if (groupValue.equals(n)) {
  hash = (String) o;
} else if (doclist.equals(n)) {
  DocList docList = (DocList) o;
  found = docList.matches();

  try {
final SolrDocumentList list =
 SolrPluginUtils.docListToSolrDocumentList(docList, searcher, fields, null);
builder.setLength(0);

if (list.size()  0)
  resultItem = solrDocumentToResultItem(list.get(0), debug);

for (final SolrDocument document : list)
  builder.append(document.getFieldValue(id)).append(',');


  } catch (final IOException e) {
LOG.error(Unexpected Error, e);
  }
}


  }

  if (found != null  found  1  resultItem != null) {
resultItem.setHash(hash);
resultItem.setFound(found);
builder.setLength(builder.length() - 1);
resultItem.setId(builder.toString());
  }

  // debug


  resultItems.add(resultItem);
}

return resultItems;




Re: SolrJ Collapsable Query Fails

2011-07-15 Thread Kurt Sultana
Hi,

Thanks for the information. However, I still have one more problem. I am
iterating over the values of the NamedList. I have 2 values, one
being 'responseHeader' and the other one being 'grouped'. I would like to
access some information stored within the grouped section, which has
data structured like so:

grouped={attr_directory={matches=4,groups=[{groupValue=C:\Users\rvassallo\Desktop\Index,doclist={numFound=2,start=0,docs=[SolrDocument[{attr_meta=[Author,
kcook, Last-Modified, 2011-03-02T14:14:18Z...

With the 'get(group)' method I am only able to access the entire
'{attr_directory={matches=4,g...' section. Is there some functionality which
allows me to get other data? Something like this for instance:
'get(group.matches)' or maybe 'get(group.attr_directory.matches)' (which
will yield the value of 4), or do I need to process the String that the
'get(...)' returns to get what I need?

Thanks :)

On Thu, Jul 14, 2011 at 12:52 PM, Ahmet Arslan iori...@yahoo.com wrote:


 See the Yonik's reply : http://search-lucene.com/m/tCmky1v94D92/

 In short you need to use NamedListObject getResponse().

  I am currently trying to run a
  collapsable query using SolrJ using SolR 3.3.
  The problem is that when I run the query through the web
  interface, with
  this url:
 
 
 http://localhost:8080/solr/select/?q=attr_content%3Alynxsort=attr_location+descgroup=truegroup.field=attr_directory
 
  I am able to see the XML which is returned. The problem
  though, is that when
  I try to run the same query through SolrJ, using this
  code:
 
  SolrQuery queryString = new
  SolrQuery();
 
  for (String param :
  query.keySet())
 
  {
  if
  (param.equals(fq))
 
  {
 
  queryString.addFilterQuery(query.get(param));
 
  }
  else
  {
 
  queryString.setParam(param, query.get(param));
 
  }
  }
 
 
  System.out.println(queryString.toString());
 
  QueryResponse response =
  server.query(queryString);
  //Exception takes place at this line
 
  SolrDocumentList docList =
  response.getResults();
 
  Which constructs a URL like so:
 
 
 q=attr_content%3Alynxsort=attr_location+descgroup=truegroup.field=attr_directory
 
  This throws an exception:
 
  Caused by: org.apache.solr.common.SolrException: parsing
  error at
 
 org.apache.solr.client.solrj.impl.XMLResponseParser.processResponse(XMLResponseParser.java:145)
  at
 
 org.apache.solr.client.solrj.impl.XMLResponseParser.processResponse(XMLResponseParser.java:106)
  at
 
 org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:477)
  at
 
 org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:244)
  at
 
 org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:89)
  ... 3 more Caused by: javax.xml.stream.XMLStreamException:
  ParseError at
  [row,col]:[3,30088] Message: error reading value:LST at
 
 org.apache.solr.client.solrj.impl.XMLResponseParser.readArray(XMLResponseParser.java:324)
  at
 
 org.apache.solr.client.solrj.impl.XMLResponseParser.readNamedList(XMLResponseParser.java:245)
  at
 
 org.apache.solr.client.solrj.impl.XMLResponseParser.readNamedList(XMLResponseParser.java:244)
  at
 
 org.apache.solr.client.solrj.impl.XMLResponseParser.readNamedList(XMLResponseParser.java:244)
  at
 
 org.apache.solr.client.solrj.impl.XMLResponseParser.processResponse(XMLResponseParser.java:130)
 
  I have tried it with both Jetty and Tomcat, the error is
  the same for both.
  I have managed to get other queries to run (with both
  servers), so I presume
  that the problem lies with this particular type of query.
 
  Any insight on this problem will be highly appreciated,
 
  Thanks :)
 



SolrJ Collapsable Query Fails

2011-07-14 Thread Kurt Sultana
I am currently trying to run a collapsable query using SolrJ using SolR 3.3.
The problem is that when I run the query through the web interface, with
this url:

http://localhost:8080/solr/select/?q=attr_content%3Alynxsort=attr_location+descgroup=truegroup.field=attr_directory

I am able to see the XML which is returned. The problem though, is that when
I try to run the same query through SolrJ, using this code:

SolrQuery queryString = new SolrQuery();

for (String param : query.keySet())

{
if (param.equals(fq))

{
queryString.addFilterQuery(query.get(param));

}
else
{
queryString.setParam(param, query.get(param));

}
}

System.out.println(queryString.toString());

QueryResponse response = server.query(queryString);
//Exception takes place at this line

SolrDocumentList docList = response.getResults();

Which constructs a URL like so:

q=attr_content%3Alynxsort=attr_location+descgroup=truegroup.field=attr_directory

This throws an exception:

Caused by: org.apache.solr.common.SolrException: parsing error at
org.apache.solr.client.solrj.impl.XMLResponseParser.processResponse(XMLResponseParser.java:145)
at
org.apache.solr.client.solrj.impl.XMLResponseParser.processResponse(XMLResponseParser.java:106)
at
org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:477)
at
org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:244)
at
org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:89)
... 3 more Caused by: javax.xml.stream.XMLStreamException: ParseError at
[row,col]:[3,30088] Message: error reading value:LST at
org.apache.solr.client.solrj.impl.XMLResponseParser.readArray(XMLResponseParser.java:324)
at
org.apache.solr.client.solrj.impl.XMLResponseParser.readNamedList(XMLResponseParser.java:245)
at
org.apache.solr.client.solrj.impl.XMLResponseParser.readNamedList(XMLResponseParser.java:244)
at
org.apache.solr.client.solrj.impl.XMLResponseParser.readNamedList(XMLResponseParser.java:244)
at
org.apache.solr.client.solrj.impl.XMLResponseParser.processResponse(XMLResponseParser.java:130)

I have tried it with both Jetty and Tomcat, the error is the same for both.
I have managed to get other queries to run (with both servers), so I presume
that the problem lies with this particular type of query.

Any insight on this problem will be highly appreciated,

Thanks :)


Re: Query problem in Solr

2011-06-03 Thread Kurt Sultana
@ Pravesh: It's 2 seperate cores, not 2 indexes. Sorry for that.

@ Erick: Yes, I've seen this suggestion and it seems to be the only possible
solution. I'll look into it.

Thanks for your answers guys!
Kurt

On Wed, Jun 1, 2011 at 4:24 PM, Erick Erickson erickerick...@gmail.comwrote:

 If I read this correctly, one approach is to specify an
 increment gap in a multiValued field, then search for phrases
 with a slop less than that increment gap. i.e.
 incrementGap=100 in your definition, and search for
 apple orange~99

 If this is gibberish, please post some examples and we'll
 try something else.

 Best
 Erick

 On Wed, Jun 1, 2011 at 4:21 AM, Kurt Sultana kurtanat...@gmail.com
 wrote:
   Hi all,
 
  We're using Solr to search on a Shop index and a Product index. Currently
 a
  Shop has a field `shop_keyword` which also contains the keywords of the
  products assigned to it. The shop keywords are separated by a space.
  Consequently, if there is a product which has a keyword apple and
 another
  which has orange, a search for shops having `Apple AND Orange` would
  return the shop for these products.
 
  However, this is incorrect since we want that a search for shops having
  `Apple AND Orange` returns shop(s) having products with both apple and
  orange as keywords.
 
  We tried solving this problem, by making shop keywords multi-valued and
  assigning the keywords of every product of the shop as a new value in
 shop
  keywords. However as was confirmed in another post
 
 http://markmail.org/thread/xce4qyzs5367yplo#query:+page:1+mid:76eerw5yqev2aanu+state:results
 ,
  Solr does not support all words must match in the same value of a
  multi-valued field.
 
  (Hope I explained myself well)
 
  How can we go about this? Ideally, we shouldn't change our search
  infrastructure dramatically.
 
  Thanks!
 
  Krt_Malta
 



Return stemmed word

2011-06-03 Thread Kurt Sultana
Hi,

We have stemming in our Solr search and we need to retrieve the word/phrase
after stemming. That is if I search for oranges, through stemming a search
for orange is carried out. If I turn on debugQuery I would be able to see
this, however we'd like to access it through the result if possible.
Basically, we need this, because we pass the searched word as a parameter to
a 3rd party application which highlights the word in an online PDF reader.
Currently, if a user searches for oranges and a document contains
orange, then the PDF wouldn't highlight anything since it tries to
highlight oranges not orange.

Thanks all in advance,
Kurt


Query problem in Solr

2011-06-01 Thread Kurt Sultana
 Hi all,

We're using Solr to search on a Shop index and a Product index. Currently a
Shop has a field `shop_keyword` which also contains the keywords of the
products assigned to it. The shop keywords are separated by a space.
Consequently, if there is a product which has a keyword apple and another
which has orange, a search for shops having `Apple AND Orange` would
return the shop for these products.

However, this is incorrect since we want that a search for shops having
`Apple AND Orange` returns shop(s) having products with both apple and
orange as keywords.

We tried solving this problem, by making shop keywords multi-valued and
assigning the keywords of every product of the shop as a new value in shop
keywords. However as was confirmed in another post
http://markmail.org/thread/xce4qyzs5367yplo#query:+page:1+mid:76eerw5yqev2aanu+state:results,
Solr does not support all words must match in the same value of a
multi-valued field.

(Hope I explained myself well)

How can we go about this? Ideally, we shouldn't change our search
infrastructure dramatically.

Thanks!

Krt_Malta


Re: Returning documents using multi-valued field

2011-05-27 Thread Kurt Sultana
Thanks for you answer James :)

For guys who would meet up with this problem,
http://markmail.org/thread/xce4qyzs5367yplo also speaks about this, and
reaches James' conclusion too.

On Thu, May 26, 2011 at 10:19 PM, Dyer, James james.d...@ingrambook.comwrote:

 This is a limitation of Lucene/Solr in that there is no way to tell it to
 not match across mutli-valued field occurences.

 A workaround is to convert your query to a phrase and add a slop factor
 less than your posititonIncrementGap.  ex:  q=alice trudy~99  ... This
 example assumes that your positionIncrementGap is set to 100 (the default I
 think) or greater.  This tells it that rather than search for a strict
 phrase, the words in the phrase can be up to 99 positions apart.  Because
 the multi-valued fields are implemented under-the-covers by simply
 increasing the position of the next occurrence by the positionIncrementGap
 value, this will effectively prevent Lucene/Solr from matching across
 occurences.

 The downside to this workaround is that wildcards are not permitted in
 phrase searches.  So if you need wildcard support also, then you're out of
 luck.

 James Dyer
 E-Commerce Systems
 Ingram Content Group
 (615) 213-4311


 -Original Message-
 From: Kurt Sultana [mailto:kurtanat...@gmail.com]
 Sent: Thursday, May 26, 2011 3:05 PM
 To: solr-user@lucene.apache.org
 Subject: Re: Returning documents using multi-valued field

 Hi, maybe I wasn't so clear in my previous post. Here's another go (I'd
 like
 a reply :) ):

 Currently I'm issuing this query on Solr:

 http://localhost:9001/solrfacetsearch/master_Shop/select/?q=%28keyword_text_mv%3A%28alice+AND+trudy%29%29+AND+%28catalogId%3A%22Default%22%29+AND+%28catalogVersion%3AOnline%29start=0rows=http://localhost:9001/solrfacetsearch/master_Shop/select/?q=%28keyword_text_mv%3A%28alice+AND+trudy%29%29+AND+%28catalogId%3A%22Default%22%29+AND+%28catalogVersion%3AOnline%29start=0rows=2147483647facet=truefacet.field=category_string_mvsort=preferred_boolean+desc%2Cgeo_distance+ascfacet.mincount=1facet.limit=50facet.sort=indexradius=111.84681460272012long=5.2864094qt=geolat=52.2119418debugQuery=on
 2147483647
 facet=truefacet.field=category_string_mvsort=preferred_boolean+desc%2Cgeo_distance+ascfacet.mincount=1facet.limit=50facet.sort=indexradius=111.84681460272012long=5.2864094qt=geolat=52.2119418debugQuery=on

 where as you can see I'm searching for keywords Alice AND Trudy. This query
 returns a document which contains:

 arr name=keyword_text_mv
 stralice jill/str
 strtrudy alex/str
 /arr

 The problem is I'd like the document to be returned only if it contains a
 string alice trudy in one of its values, in other words, if it contains :

 arr name=keyword_text_mv
 stralice trudy/str
 strjill alex/str
 /arr

 How could I achieve this? I'm supporting the code written by someone else
 and I'm quite new to Solr.

 Thanks in advance :)

 Kurt


 On Wed, May 25, 2011 at 11:44 AM, Kurt Sultana kurtanat...@gmail.com
 wrote:

 
  Hi all,
 
  I'm quite new to Solr and I'm supporting an existing Solr search engine
  which was written by someone else. I've been reading on Solr for the last
  couple of weeks so I'd consider myself beyond the basics.
 
  A particular field, let's say name, is multi-valued. For example, a
  document has a field name with values Alice, Trudy. We want that the
  document is returned when Alice or Trudy is input and not when Alice
  Trudy is entered. Currently the document is even with Alice Trudy. How
  could this be done?
 
  Thanks a lot!
  Kurt
 
 



Re: Returning documents using multi-valued field

2011-05-26 Thread Kurt Sultana
Hi, maybe I wasn't so clear in my previous post. Here's another go (I'd like
a reply :) ):

Currently I'm issuing this query on Solr:
http://localhost:9001/solrfacetsearch/master_Shop/select/?q=%28keyword_text_mv%3A%28alice+AND+trudy%29%29+AND+%28catalogId%3A%22Default%22%29+AND+%28catalogVersion%3AOnline%29start=0rows=2147483647facet=truefacet.field=category_string_mvsort=preferred_boolean+desc%2Cgeo_distance+ascfacet.mincount=1facet.limit=50facet.sort=indexradius=111.84681460272012long=5.2864094qt=geolat=52.2119418debugQuery=on

where as you can see I'm searching for keywords Alice AND Trudy. This query
returns a document which contains:

arr name=keyword_text_mv
stralice jill/str
strtrudy alex/str
/arr

The problem is I'd like the document to be returned only if it contains a
string alice trudy in one of its values, in other words, if it contains :

arr name=keyword_text_mv
stralice trudy/str
strjill alex/str
/arr

How could I achieve this? I'm supporting the code written by someone else
and I'm quite new to Solr.

Thanks in advance :)

Kurt


On Wed, May 25, 2011 at 11:44 AM, Kurt Sultana kurtanat...@gmail.comwrote:


 Hi all,

 I'm quite new to Solr and I'm supporting an existing Solr search engine
 which was written by someone else. I've been reading on Solr for the last
 couple of weeks so I'd consider myself beyond the basics.

 A particular field, let's say name, is multi-valued. For example, a
 document has a field name with values Alice, Trudy. We want that the
 document is returned when Alice or Trudy is input and not when Alice
 Trudy is entered. Currently the document is even with Alice Trudy. How
 could this be done?

 Thanks a lot!
 Kurt




Returning documents using multi-valued field

2011-05-25 Thread Kurt Sultana
Hi all,

I'm quite new to Solr and I'm supporting an existing Solr search engine
which was written by someone else. I've been reading on Solr for the last
couple of weeks so I'd consider myself beyond the basics.

A particular field, let's say name, is multi-valued. For example, a document
has a field name with values Alice, Trudy. We want that the document is
returned when Alice or Trudy is input and not when Alice Trudy is
entered. Currently the document is even with Alice Trudy. How could this
be done?

Thanks a lot!
Kurt