Thanks for the tip. I'm trying to decipher what the explanation
tells me right now.
Btw, here is the code that I'm currently running:
////////
QueryParser nameParser = new QueryParser("name", analyzer);
QueryParser categoryParser = new QueryParser("category", analyzer);
QueryParser descriptionParser = new QueryParser("description",
analyzer);
QueryParser featuresParser = new QueryParser("features", analyzer);
QueryParser specificationsParser = new QueryParser("specifications",
analyzer);
QueryParser skuParser = new QueryParser("sku", analyzer);
QueryParser modelParser = new QueryParser("model", analyzer);
descriptionParser.setDefaultOperator(QueryParser.Operator.AND);
featuresParser.setDefaultOperator(QueryParser.Operator.AND);
specificationsParser.setDefaultOperator(QueryParser.Operator.AND);
BooleanQuery booleanQuery = new BooleanQuery();
Query current = null;
current = categoryParser.parse(queryString);
current.setBoost(20.0f);
booleanQuery.add(current, BooleanClause.Occur.SHOULD);
booleanQuery.add(nameParser.parse(queryString),
BooleanClause.Occur.SHOULD);
booleanQuery.add(descriptionParser.parse(queryString),
BooleanClause.Occur.SHOULD);
booleanQuery.add(featuresParser.parse(queryString),
BooleanClause.Occur.SHOULD);
booleanQuery.add(specificationsParser.parse(queryString),
BooleanClause.Occur.SHOULD);
booleanQuery.add(skuParser.parse(queryString),
BooleanClause.Occur.SHOULD);
booleanQuery.add(modelParser.parse(queryString),
BooleanClause.Occur.SHOULD);
hits = indexSearcher.search(booleanQuery);
hits = indexSearcher.search(booleanQuery, Sort.RELEVANCE);
////////
Looking at the results, the first document in the results should
hopefully be near the bottom and the Explanation for this document
has a Description/Details (using the toString() on the Explanation) of:
product of:
0.0 = sum of:
0.0 = coord(0/7)
So I'm kind of at a loss as to what's going on. Am I just doing
something crazy weird in my code? I didn't find that many examples
out there, so I'm kind of winging it according to what I've read in
the javadocs and what examples I could find.
Thanks,
Jeremy
On Apr 13, 2006, at 6:17 PM, Erik Hatcher wrote:
The best recommendation is to have a look at the Explanation
returned from IndexSearcher.explain() for a specific query and
document to trace how things are being scored. Is it possible
you're boosting all documents by the same amount?
Erik
On Apr 13, 2006, at 6:29 PM, Jeremy Hanna wrote:
I have a situation where I'm indexing database entries and have
fields such as:
name
sku
model
category name
description
features
specifications
I am trying to set a priority higher for the name, category name,
and description.
I've tried setting the fields' boost values as I've indexed the db
and it seemed to have little or no result.
When I tried to do the queries, I started using the
MultiFieldQueryParser but found that those don't have priority or
boost values you can set on any of the Fields at query time. Then
I tried to have separate query parsers - one for each field. That
way I could set a boost level for each of the queries created by
those query parsers. I joined them together with a BooleanQuery
and all of them set to BooleanQuery.Occur.SHOULD. I ended up
setting the features, specifications, and description to default
to Query.Operator.AND and that helped, but the boost value seems
to do nothing.
I try to set the categoryParser's query boost to 4.0f, then 8.0f,
then 20.0f and have tried downgrading other queries, but the
results don't change at all in their order.
I am using 1.9.1 and for my database I'm using hibernate to mysql
5 and ArrayLists with the bag mapping in hibernate.
Does anyone have any thoughts or suggestions?
Thanks!
Jeremy
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]