About SolrJ for XML
Hi, I am new in Solr. I am using Solr version 1.3 I would like to index XML files using SolrJ API. I have gone through solr mailing list's emails and have been able to index XML files. But when I try to query on those files using SolrJ, I get no output. Especially, I do not find correct results for numeric fields that I have specified in the schema.xml file in the config directory for my XML files. I have made those fields "indexed" and "stored" by using "indexed=true" and "stored=true". I am using the following code in order to search for data (In the following code, I am trying to find out weight with values 21) - SolrQuery query = new SolrQuery(); query.setQueryType("dismax"); query.setFacet(true); query.addFacetField("id"); query.addFacetField("weight"); query.setQuery("21"); QueryResponse qr = server.query(query); SolrDocumentList sdl = qr.getResults(); Am I doing anything wrong? Why do I get zero results even when there is a XML file with weight being 21. What are the other ways of doing the numeric queries in SolrJ ? Also, I would like to know how do I get the exact size of the index being generated by Solr. I am using a single machine to generate and query the index. When I look at the index directory, I see that the size of the files in the index directory is much lesser than the size reported by the "total" column in "ls -lh" command. Does anyone have any idea why is it the case? Thanks in advance. Waiting for your reply soon. Regards Chaitali
RE: About SolrJ for XML
Hi, Thanks a lot. It worked!! I was wondering if there is a way in SolrJ to print out the size of the index being generated? Or else how do I determine the total size of the generated index ? Thanks, Chaitali --- On Mon, 10/5/09, Feak, Todd wrote: From: Feak, Todd Subject: RE: About SolrJ for XML To: "solr-user@lucene.apache.org" Date: Monday, October 5, 2009, 5:17 PM It looks like you have some confusion about queries vs. facets. You may want to look at the Solr wiki reqarding facets a bit. In the meanwhile, if you just want to query for that field containing "21"... I would suggest that you don't set the query type, don't set any facet fields, and only set the query. Set the query to "field:21" where "field" should be replaced with the fieldname that has a "21" in it. For example, if the field name is foo, try this instead: SolrQuery query = new SolrQuery(); query.setQuery("foo:21"); QueryResponse qr = server.query(query); SolrDocumentList sdl = qr.getResults(); To delve into more detail, what your original code did was query for a "21" in the default field (check your solrconfig.xml to see what is default). It then faceted the query results by the "id" field and "weight" fields. Because there were no search results at all, the faceting request didn't do anything. I'm not sure why you switched the query type to DisMax, as you didn't issue a query that would leverage it. -Todd -Original Message- From: Chaitali Gupta [mailto:chaitaligupt...@yahoo.com] Sent: Monday, October 05, 2009 2:05 PM To: solr-user@lucene.apache.org Subject: About SolrJ for XML Hi, I am new in Solr. I am using Solr version 1.3 I would like to index XML files using SolrJ API. I have gone through solr mailing list's emails and have been able to index XML files. But when I try to query on those files using SolrJ, I get no output. Especially, I do not find correct results for numeric fields that I have specified in the schema.xml file in the config directory for my XML files. I have made those fields "indexed" and "stored" by using "indexed=true" and "stored=true". I am using the following code in order to search for data (In the following code, I am trying to find out weight with values 21) - SolrQuery query = new SolrQuery(); query.setQueryType("dismax"); query.setFacet(true); query.addFacetField("id"); query.addFacetField("weight"); query.setQuery("21"); QueryResponse qr = server.query(query); SolrDocumentList sdl = qr.getResults(); Am I doing anything wrong? Why do I get zero results even when there is a XML file with weight being 21. What are the other ways of doing the numeric queries in SolrJ ? Also, I would like to know how do I get the exact size of the index being generated by Solr. I am using a single machine to generate and query the index. When I look at the index directory, I see that the size of the files in the index directory is much lesser than the size reported by the "total" column in "ls -lh" command. Does anyone have any idea why is it the case? Thanks in advance. Waiting for your reply soon. Regards Chaitali
Re: dose solr sopport distribute index storage ?
Hi, How should we setup master and slaves in Solr? What configuration files and parameters should we need to change and how ? Thanks, Chaitali --- On Mon, 10/12/09, Shalin Shekhar Mangar wrote: From: Shalin Shekhar Mangar Subject: Re: dose solr sopport distribute index storage ? To: solr-user@lucene.apache.org Date: Monday, October 12, 2009, 3:17 AM On Mon, Oct 12, 2009 at 10:27 AM, Pravin Karne < pravin_ka...@persistent.co.in> wrote: > How to set master/slave setup for solr. > > Index documents only on the master. Put the slaves behind a load balancer and query only on slaves. Setup replication between the master and slaves. See http://wiki.apache.org/solr/SolrReplication -- Regards, Shalin Shekhar Mangar.
Error when indexing XML files
Hi, I am trying to index XML files using SolrJ. The original XML file contains nested elements. For example, the following is the snippet of the XML file. SOMETHING SOME_OTHER_THING I have added the elements "name" and "facility" in Schema.xml file to make these elements indexable. I have changed the XML document above to look like - .. SOMETHING .. I am getting the following error when I start Jetty - "org.apache.solr.common.SolrException: ERROR_5457843_multiple_values_encountered_for_non_multiValued_field_facility___tracklesstrackless_" Can anyone please let me know if there is something I am doing wrong ? How can I maintain the parent-child relationship of the original XML file in the modified XML file? Can I not use the original XML file as it is for indexing purposes? Thanks in advance. - Chaitali
Re: Error when indexing XML files
Hi, Please find the schema file attached. Please let me know what I am doing wrong. Regards Chaitali --- On Wed, 10/14/09, Fergus McMenemie wrote: From: Fergus McMenemie Subject: Re: Error when indexing XML files To: solr-user@lucene.apache.org Date: Wednesday, October 14, 2009, 2:25 AM >Hi, > >I am trying to index XML files using SolrJ. The original XML file contains >nested elements. For example, the following is the snippet of the XML file. > > > SOMETHING > SOME_OTHER_THING > > >I have added the elements "name" and "facility" in Schema.xml file to make >these elements indexable. I have changed the XML document above to look like - > > > > .. > SOMETHING > .. > > > Can you send us the Schema.xml file you created? I suspect that one of the fields should be multivalued. -- Fergus. id text