Hi, I hope that someone can help me. I have intention to use xapian for one portal of mine in which the consumers can post messages that are divided for category. When I index a new post I also add to the object document the value with the name of the category. How can I exploit all of this to effect searches filtered in base to the category? Is there another way to do it without using the meta-data value? Thanks Francesco Bruno
2009/5/18 Senior Boss <seniorboss at hotmail.it>> Hi, I hope that someone can help me. I have intention to use xapian for one > portal of mine in which > the consumers can post messages that are divided for category. > When I index a new post I also add to the object document the value with > the name of the category. > How can I exploit all of this to effect searches filtered in base to the > category? > Is there another way to do it without using the meta-data value?Hi Francesco, If I understand you correctly, the usual way to do this would be to add a term with a unique prefix to the document, e.g. (in pseudo-code): doc.add_term('XC' + category_name); ... db.add_document(doc); Then for filtering searches, add a subquery with the OP_FILTER operator: filter_query = Query('XC' + category_name); query = Query(OP_FILTER, user_query, filter_query); Hope this helps. Tom
Hello, maybe using multiple indexes, i.e. one per category ? I don't know how many caterogies you have, but it can be a way for you, as Xapian can search in multiple indexes (I use this at work, it's really easy). Regards, C. On Mon, 18 May 2009 12:07:19 +0200 "Senior Boss" <seniorboss at hotmail.it> wrote:> Hi, I hope that someone can help me. I have intention to use xapian for one portal of mine in which > the consumers can post messages that are divided for category. > When I index a new post I also add to the object document the value with the name of the category. > How can I exploit all of this to effect searches filtered in base to the category? > Is there another way to do it without using the meta-data value? > Thanks > > Francesco Bruno > _______________________________________________ > Xapian-discuss mailing list > Xapian-discuss at lists.xapian.org > http://lists.xapian.org/mailman/listinfo/xapian-discuss-- C?dric Jeanneret | System Administrator 021 619 10 32 | Camptocamp SA cedric.jeanneret at camptocamp.com | PSE-A / EPFL
Hi Tom and thanks for the rapidity in to answer me. I have followed your indications and it is really what i'm looking for. Unfortunately the search doesn't produce any result while in the db the searched record is present. I insert here following the code that I have used (Php). Is there something of wrong? For the indexer $doc->add_term('XC'.$category); ... $db->add_document($doc); For the search $user_query = "blu red"; $filter_query = "XCcategory1"; $query = new XapianQuery(XapianQuery::OP_FILTER, $user_query, $filter_query); $enquire->set_query($query); $matches = $enquire->get_mset(0, 10); The output result is Parsed query is: Xapian::Query((blu red FILTER XCcat1)) 0 results found: MESSAGGIO ORIGINALE 2009/5/18 Senior Boss <seniorboss at hotmail.it> Hi, I hope that someone can help me. I have intention to use xapian for one portal of mine in which the consumers can post messages that are divided for category. When I index a new post I also add to the object document the value with the name of the category. How can I exploit all of this to effect searches filtered in base to the category? Is there another way to do it without using the meta-data value? Hi Francesco, If I understand you correctly, the usual way to do this would be to add a term with a unique prefix to the document, e.g. (in pseudo-code): doc.add_term('XC' + category_name); ... db.add_document(doc); Then for filtering searches, add a subquery with the OP_FILTER operator: filter_query = Query('XC' + category_name); query = Query(OP_FILTER, user_query, filter_query); Hope this helps. Tom MESSAGGIO ORIGINALE