Re: Hierarchical faceting
Thank you for your answer. I sure will implement something in that direction. But couldn't multiple tokens be used instead of multiple values? fieldType name=hier class=solr.TextField analyzer type=index // some tokenizer and filters that generates 0//Europe, 1//Europe//Norway, 2//Europe//Norway//Oslo /analyzer /fieldType field name=country_facet type=hier indexed=true stored=true/ Wouldn't that work in just the same way? Or is it some difference between multiple tokens and multiple values that I'm missing? -- Regards, Mats Bolstad On Fri, Aug 13, 2010 at 2:21 AM, Jayendra Patil jayendra.patil@gmail.com wrote: We were able to get the hierarchy faceting working with a work around approach. e.g. if you have Europe//Norway//Oslo as an entry 1. Create a new multivalued field with string type field name=country_facet type=string indexed=true stored=true multiValued=true/ 2. Index the field for Europe//Norway//Oslo with values 0//Europe 1//Europe//Norway 2//Europe//Norway//Oslo 3. The Facet can now be used in the Queries :- 1st Level - Would return all entries @ 1st level e.g. 0//USA, 0//Europe fq= f.country_facet.facet.prefix=0// facet.field=country_facet 2nd Level - Would return all entries @ second level in Europe 1//Europe//Norway, 1//Europe//Sweden fq=country_facet:0//Europe f.country_facet.facet.prefix=1//Europe facet.field=country_facet 3rd Level - Would return 1//Europe//Norway entries fq=country_facet:1//Europe//Norway f.country_facet.facet.prefix=2//Europe//Norway facet.field=country_facet Increment the facet.prefix by 1 so that you limit the facet results to to that prefix. Also works for any depth. Regards, Jayendra On Thu, Aug 12, 2010 at 6:01 PM, Mats Bolstad mat...@stud.ntnu.no wrote: Hey all, I am doing a search on hierarchical data, and I have a hard time getting my head around the following problem. I want a result as follows, in one single query only: USA (3) California (2) Arizona (1) Europe (4) Norway (3) Oslo (3) Sweden (1) How it looks in the XML/JSON response is not really important, this is more a presentation issue. I guess I could store the values USA, USA/California, Europe/Norway/Oslo as strings for each document, and do some JavaScript-ing to show the hierarchies appropriately. When a specific item in the facet is selected, for example Norway, Solr could be queries with a filter query on Europe/Norway*? Do anyone have some experiences they could please share with me? I have tried out SOLR-64, and it gives me the results I look for. However, I do not have the opportunity to use a patch in the production environment ... -- Thanks, Mats Bolstad
Hierarchical faceting
Hey all, I am doing a search on hierarchical data, and I have a hard time getting my head around the following problem. I want a result as follows, in one single query only: USA (3) California (2) Arizona (1) Europe (4) Norway (3) Oslo (3) Sweden (1) How it looks in the XML/JSON response is not really important, this is more a presentation issue. I guess I could store the values USA, USA/California, Europe/Norway/Oslo as strings for each document, and do some JavaScript-ing to show the hierarchies appropriately. When a specific item in the facet is selected, for example Norway, Solr could be queries with a filter query on Europe/Norway*? Do anyone have some experiences they could please share with me? I have tried out SOLR-64, and it gives me the results I look for. However, I do not have the opportunity to use a patch in the production environment ... -- Thanks, Mats Bolstad
Re: SolrJ Response + JSON
If you don't mind your JSON format complying with the one Solr uses, you could use GSON. SolrQuery solrQuery = new SolrQuery(your query); QueryResponse response = server.query(solrQuery); List beans = response.getBeans(YourObject.class); // some computing ... GSON gson = new GSON(); String json = gson.toJSON(beans); Mats Bolstad On Wed, Jul 28, 2010 at 1:54 PM, MitchK mitc...@web.de wrote: Hello community, I need to transform SolrJ - responses into JSON, after some computing on those results by another application has finished. I can not do those computations on the Solr - side. So, I really have to translate SolrJ's output into JSON. Any experiences how to do so without writing your own JSON-writer? Thank you. - Mitch -- View this message in context: http://lucene.472066.n3.nabble.com/SolrJ-Response-JSON-tp1002024p1002024.html Sent from the Solr - User mailing list archive at Nabble.com.
Re: SolrJ Response + JSON
What I meant is that GSON do not wrap the response as follows: { responseHeader:{ status:0, QTime:x}, response:{numFound:x,start:0,docs:[ { /* docs */ }] }, facet_counts:{ facet_queries:{}, facet_fields:{}, facet_dates:{}}} If you care to preserve this format/pattern/whatever, you would need to insert the JSON produced by GSON into such a body, and generate the other attributes yourself. That might not be needed, nor difficult to implement. BUT it's not done out-of-the-box :) For the application I'm developing I have a similar concern. I want to do some authorizing and removing/adding content on the docs before I send them off to the user. As I've already invested a lot of time developing client-side code I want to preserve the exact same JSON format. Mats Bolstad On Thu, Jul 29, 2010 at 12:40 PM, Mitch Köhler mitc...@web.de wrote: Hi Mat, sounds very interesting, because it seems to be so easy. You say, that this could comply with Solr's JSON-format. What are your experiences regarding the differences? I mean, JSON is a standard, so what can be different? Thank you! - Mitch Am 29.07.2010 09:42, schrieb Mats Bolstad: If you don't mind your JSON format complying with the one Solr uses, you could use GSON. SolrQuery solrQuery = new SolrQuery(your query); QueryResponse response = server.query(solrQuery); List beans = response.getBeans(YourObject.class); // some computing ... GSON gson = new GSON(); String json = gson.toJSON(beans); Mats Bolstad On Wed, Jul 28, 2010 at 1:54 PM, MitchKmitc...@web.de wrote: Hello community, I need to transform SolrJ - responses into JSON, after some computing on those results by another application has finished. I can not do those computations on the Solr - side. So, I really have to translate SolrJ's output into JSON. Any experiences how to do so without writing your own JSON-writer? Thank you. - Mitch -- View this message in context: http://lucene.472066.n3.nabble.com/SolrJ-Response-JSON-tp1002024p1002024.html Sent from the Solr - User mailing list archive at Nabble.com.
Re: myField:value does not seem to work
Type string is not tokenized, meaning that it would match only the exact phrase Khai Bright T. Use text (or another) type that tokenizes (on whitespace in this case) instead. Mats Bolstad On Thu, Jul 29, 2010 at 9:55 PM, Khai Doan khaitd...@gmail.com wrote: Hi Yonik, Here is the field definition in schema.xml: field name=membername type=string indexed=true stored=true/ and it is populated with Khai Bright T I am using solr 1.4.1 Khai On Thu, Jul 29, 2010 at 12:49 PM, Yonik Seeley yo...@lucidimagination.comwrote: Is membername an indexed field in the schema, and was it populated with something that would match Khai? If so, what is the fieldType in the schema for the membername field? -Yonik http://www.lucidimagination.com On Thu, Jul 29, 2010 at 3:17 PM, Khai Doan khaitd...@gmail.com wrote: Hello, My name is Khai. I am new to Solr, and I am having a strange issue. I use the admin interface and search for Khai and it work fine. However if I type membername:Khai it does not work. Please provide me with hints on what the issue may be. Thank you, Khai
Re: myField:value does not seem to work
Put simply, strings do not go through filters, and will need exact matching. A string field can typically be an ID field. Texts go through filters so that bar could match Foo Bars, for example. Types are well documented in the example schema.xml shipped with solr. You would also find more info in the wiki. On 29. juli 2010, at 22:53, Khai Doan khaitd...@gmail.com wrote: What are the differences between string and text? What other types (that are available by default) can I use? Thanks, Khai On Thu, Jul 29, 2010 at 1:30 PM, Mats Bolstad mat...@stud.ntnu.no wrote: Type string is not tokenized, meaning that it would match only the exact phrase Khai Bright T. Use text (or another) type that tokenizes (on whitespace in this case) instead. Mats Bolstad On Thu, Jul 29, 2010 at 9:55 PM, Khai Doan khaitd...@gmail.com wrote: Hi Yonik, Here is the field definition in schema.xml: field name=membername type=string indexed=true stored=true/ and it is populated with Khai Bright T I am using solr 1.4.1 Khai On Thu, Jul 29, 2010 at 12:49 PM, Yonik Seeley yo...@lucidimagination.comwrote: Is membername an indexed field in the schema, and was it populated with something that would match Khai? If so, what is the fieldType in the schema for the membername field? -Yonik http://www.lucidimagination.com On Thu, Jul 29, 2010 at 3:17 PM, Khai Doan khaitd...@gmail.com wrote: Hello, My name is Khai. I am new to Solr, and I am having a strange issue. I use the admin interface and search for Khai and it work fine. However if I type membername:Khai it does not work. Please provide me with hints on what the issue may be. Thank you, Khai
Problems with type mismatch on SolrJ annotations
Hey all! I have a problem with how solrj makes beans from a solr response. Very simplified my business objects are as follows: enum E { ENUM1, ENUM2; } public class A { @Field(a_id) private String id; @Field(a_type) private E objectType; public void setId(String id) { this.id = id; } public String getId() { return id; } public void setObjectType(String type) { if (type.equals(something) this.type = E.ENUM1; else this.type = E.ENUM2; } public String getObjectType() { return type.toString(); } } In other words, I try to encapsulate an enum within A, while to the public it seems like a String. In the Solr index, the a_type field is a string. To follow Java conventions, I would like to access objectType through getters and setters, but Solr doesn't let me do that, as it complains: java.lang.IllegalArgumentException: Can not set E field A.objectType to java.lang.String Are there any ways around this, except the obvious of changing the type of objectType to String? I tried moving the @Field annotation to the getter and setter with no luck... -- Regards Mats Bolstad