Created
June 2, 2011 17:31
-
-
Save phillipuniverse/1004865 to your computer and use it in GitHub Desktop.
Andre Compass Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public List<PBProductTire> findTiresForSize(String width, String ratio, String diameter, String passOrLightTruck, String ratingOrRange) { | |
String query = "alias:PBProductTire AND tireWidth:" + width + " AND tireRatio:" + ratio + " AND tireDiameter:" + diameter; | |
if (passOrLightTruck.equals("LT")) { | |
query += " AND tireType:LT"; | |
} else { | |
query += " AND NOT tireType:LT"; | |
} | |
CompassSearchSession session = compass.openSearchSession(); | |
CompassDetachedHits hits = session.find(query).detach(); | |
session.close(); | |
List<PBProductTire> results = new ArrayList<PBProductTire>(hits.length()); | |
for (int i = 0; i < hits.length(); i++) { | |
PBProductTire tire = (PBProductTire) catalogService.findProductById(((PBProductTire) hits.data(i)).getId()); | |
if ((passOrLightTruck.equals("LT") && tireLogicService.meetsLoadRange(tire, ratingOrRange)) | |
|| (tireLogicService.meetsSpeedRating(tire, ratingOrRange))) { | |
results.add(tire); | |
} | |
} | |
return results; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment