- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
public static Document getDoc(CarPartsAd ad) {
Document doc = new Document();
doc.add(new Field("id", ad.getId().toString(), YES, NOT_ANALYZED));
doc.add(new Field("mark", Long.toString(ad.getMarkId()), Field.Store.NO, NOT_ANALYZED));
doc.add(new Field("model", Long.toString(ad.getModelId()), Field.Store.NO, NOT_ANALYZED));
doc.add(new Field("frame", Long.toString(ad.getFrameId()), Field.Store.NO, NOT_ANALYZED));
doc.add(new Field("engine", Long.toString(ad.getEngineId()), Field.Store.NO, NOT_ANALYZED));
doc.add(new Field("type", Long.toString(ad.getTypeId()), Field.Store.NO, NOT_ANALYZED));
doc.add(new Field("front_rear", Long.toString(ad.getFrontRear()), Field.Store.NO, NOT_ANALYZED));
doc.add(new Field("right_left", Long.toString(ad.getRightLeft()), Field.Store.NO, NOT_ANALYZED));
doc.add(new Field("up_down", Long.toString(ad.getUpDown()), Field.Store.NO, NOT_ANALYZED));
doc.add(new Field("contact", Long.toString(ad.getContactId()), Field.Store.NO, NOT_ANALYZED));
doc.add(new Field("town", Long.toString(ad.getTownId()), Field.Store.NO, NOT_ANALYZED));
doc.add(new Field("part_state", Long.toString(ad.getPartState()), Field.Store.NO, NOT_ANALYZED));
doc.add(new Field("original_flag", Long.toString(ad.getOriginalFlag()), Field.Store.NO, NOT_ANALYZED));
doc.add(new Field("price", Integer.toString(ad.getPriceRub()), Field.Store.YES, NOT_ANALYZED));
doc.add(new Field("price_flag", (ad.getPriceRub() > 0 ? "0" : "1"), Field.Store.NO, NOT_ANALYZED));
doc.add(new Field("date_sort", Long.toString(ad.getSort()).substring(0, 9), Field.Store.YES, NOT_ANALYZED));
doc.add(new Field("oem", format(ad.getOem()).replaceAll(" ", "").toLowerCase(), Field.Store.NO, NOT_ANALYZED));
doc.add(new Field("producer_code", format(ad.getProducerCode()).replaceAll(" ", "").toLowerCase(), Field.Store.NO, NOT_ANALYZED));
doc.add(new Field("uplift_rating", Integer.toString(ad.getUpliftRating()), Field.Store.NO, NOT_ANALYZED));
doc.add(new Field("ads_source", Integer.toString(ad.getAdsSource()), Field.Store.NO, NOT_ANALYZED));
return doc;
}
лучик ненависти авторам lucene за то, что заставляют писать такое :)