Hello, I need to do a search like: Query = "my product title" OR blue OR brown AND Department = Electronics
A user would enter in a textbox the search as: "my product title" blue brown ---- I would add the specific part of the query by Department the user was browsing so they would not enter that in the textbox.
This woul equate to a "phrase search" and then an OR search on the rest of the search terms.
Can this be done in one query? Should this use a LuceneQuery?
Is there a place to understand when to use LucenQuery, Search() or Where() ... etc... I see bits here and there, but hard to find an example when you need it.
I created an index like:
public class Product_Search : AbstractIndexCreationTask<Product, Product_Search.SearchResult> {
public class SearchResult {
public string Query { get; set; }
public DateTimeOffset Created { get; set; }
public string Department { get; set; }
}
public Product_Search() {
Map = products =>
from product in products
select new {
Query = new object[]
{
product.Title,
product.Category,
product.Color
},
product.Created,
product.Deparment
};
Index( x => x.Query, FieldIndexing.Analyzed );
}
}
Also, I would need a case-insensitive search as well. Am I going in the right direction? If the index is correct, what is the correct way to query this? LuceneQuery, using the Index and .Search(), etc.?
Thanks a bunch!
Troy