Good Evening , Please help me
Search string: valve size 100mm bearing
1) If Iam searching for above string I should be able to get all data containing valve in first place and then size like wise, currently I am getting any data containing all 4 words
2) If iam searching for string with special characters it should be matched, say for example if I am searching for valve p/n it should be searchable
------------------------------------------------------------------------------------------------------ @Entity @Indexed @Table(name = "MV_SMART_SEARCH_TEXT_REP", schema = "VISION_DEV")
public class SmartSearch implements java.io.Serializable {
private String rowId; private String recordNo; private String erpsfd; private String purchase; private String descriptor; private String locale; private String orgnId; private String region; private String qualityLevel; private String trustLevel; private String activeStatus;
public SmartSearch() { }
public SmartSearch(String recordNo, String erpsfd, String purchase, String descriptor, String locale, String orgnId, String region) { this.recordNo = recordNo; this.erpsfd = erpsfd; this.purchase = purchase; this.descriptor = descriptor; this.locale = locale; this.orgnId = orgnId; this.region = region; }
@Id @Column(name = "ROW_ID", nullable = false, length = 80) public String getRowId() { return rowId; }
public void setRowId(String rowId) { this.rowId = rowId; }
@Column(name = "RECORD_NO", nullable = false, length = 80) @Fields({ @Field(name = "recordNo", index = Index.YES, analyze = Analyze.YES, store = Store.NO), @Field(name = "recordNo_sort", index = Index.YES, analyze = Analyze.NO, store = Store.NO) }) //@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO) public String getRecordNo() { return this.recordNo; }
public void setRecordNo(String recordNo) { this.recordNo = recordNo; }
// @Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO) @Fields({ @Field(name = "erpsfd", index = Index.YES, analyze = Analyze.YES, store = Store.NO), @Field(name = "erpsfd_sort", index = Index.YES, analyze = Analyze.NO, store = Store.NO) })
@Column(name = "ERPSFD", nullable = false, length = 4000) public String getErpsfd() { return this.erpsfd; }
public void setErpsfd(String erpsfd) { this.erpsfd = erpsfd; }
//@Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES, termVector = TermVector.WITH_POSITION_OFFSETS) //@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO) @Fields({ @Field(name = "purchase", index = Index.YES, analyze = Analyze.YES, store = Store.NO), @Field(name = "purchase_sort", index = Index.YES, analyze = Analyze.NO, store = Store.NO) })
@Column(name = "PURCHASE", nullable = false, length = 4000) public String getPurchase() { return this.purchase; }
public void setPurchase(String purchase) { this.purchase = purchase; }
@Fields({ @Field(name = "descriptor", index = Index.YES, analyze = Analyze.YES, store = Store.NO), @Field(name = "descriptor_sort", index = Index.YES, analyze = Analyze.NO, store = Store.NO) }) // @Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO) @Column(name = "CLASS", length = 4000) @Sort
public String getDescriptor() { return descriptor; }
public void setDescriptor(String descriptor) { this.descriptor = descriptor; }
//@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO) @Fields({ @Field(name = "locale", index = Index.YES, analyze = Analyze.YES, store = Store.NO), @Field(name = "locale_sort", index = Index.YES, analyze = Analyze.NO, store = Store.NO) })
@Column(name = "LOCALE", nullable = false, length = 20) public String getLocale() { return this.locale; }
public void setLocale(String locale) { this.locale = locale; }
@Column(name = "ORGN_ID", nullable = false) public String getOrgnId() { return this.orgnId; }
public void setOrgnId(String orgnId) { this.orgnId = orgnId; }
@Column(name = "REGION", nullable = false, length = 80) public String getRegion() { return this.region; }
public void setRegion(String region) { this.region = region; } //-creatd new
// @Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO) @Fields({ @Field(name = "qualityLevel", index = Index.YES, analyze = Analyze.YES, store = Store.NO), @Field(name = "qualityLevel_sort", index = Index.YES, analyze = Analyze.NO, store = Store.NO) })
@Column(name = "QUALITY_LEVEL", nullable = false, length = 80) public String getQualityLevel() { return qualityLevel; }
public void setQualityLevel(String qualityLevel) { this.qualityLevel = qualityLevel; }
//@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO) @Fields({ @Field(name = "trustLevel", index = Index.YES, analyze = Analyze.YES, store = Store.NO), @Field(name = "trustLevel_sort", index = Index.YES, analyze = Analyze.NO, store = Store.NO) })
@Column(name = "TRUST_LEVEl", nullable = false, length = 80) public String getTrustLevel() { return trustLevel; }
public void setTrustLevel(String trustLevel) { this.trustLevel = trustLevel; }
//@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO) @Fields({ @Field(name = "activeStatus", index = Index.YES, analyze = Analyze.YES, store = Store.NO), @Field(name = "activeStatus_sort", index = Index.YES, analyze = Analyze.NO, store = Store.NO) }) @Column(name = "ACTIVE_STATUS", nullable = false, length = 80) public String getActiveStatus() { return activeStatus; }
public void setActiveStatus(String activeStatus) { this.activeStatus = activeStatus; }
}
dao ---- resultjsArray = new JSONArray(); fullTextSession = Search.getFullTextSession(access.getSessionFactory().getCurrentSession()); SearchFactory searchFactory = fullTextSession.getSearchFactory(); searchClass = getApplicationPropertyValue("MM_SEARCH_VIEW_NAME");
if (searchClass == null) { searchClass = SmartSearch.class; }
QueryBuilder b = fullTextSession.getSearchFactory() .buildQueryBuilder().forEntity(searchClass).get();
BooleanQuery booleanQuery = new BooleanQuery(); String[] splitArray = textData.split("\\s");
int g = 0; String searchtext = ""; PrefixQuery pfxQuery = null; String nativeluceneQuery = ""; for (String splitArray1 : splitArray) { luceneQuery = b.keyword().wildcard().onField("purchase").matching(splitArray1 + "*").createQuery(); booleanQuery.add(luceneQuery, BooleanClause.Occur.MUST); } FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery(booleanQuery); fullTextQuery.setMaxResults(10); listitems = fullTextQuery.list();
|