简体   繁体   中英

Different search results for e-commerce site

If i have to design a site which give different type of search criteria and it keeps on changing, is there some pattern i need to follow?.

For example, i have a search criteria to search by Category. Later on i decide to put an extra criteria to search by price. It can have combinations too for the above criteria. After some time i add one more criteria, search by location, but then i need to keep on changing the class that is returning me the result.

public List<Product> GetProducts(SearchCriteria search){
      //code
}


public class SearchCriteria{
     public string Category{get;set;}
     public double Price{get;set;}
}

So if i need to add another criteria, i need to change the SearchCriteria class and the GetProducts method.

There is a really good search platform provided by Apache known as Solr

which comes with a java API known as SolrJ .

I think if you spend some time studying it, you will find your answer easily solved, plus you will be able to use some extra features provided by it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM