문제점 : 단어 문서를 업로드 할 때 제목 (문서를 업로드하는 동안 입력 됨)과 요약을 검색 할 수 있지만 문서의 일부 텍스트를 사용하여 검색 할 때 나는 결과를 얻고있다.ClassBridge 후크로 문서의 Lucene 색인이 작동하지 않습니다.
내가 사용하고 있습니다 "- 최대 절전 모드 검색 엔진 : 4.3.0.Final을 루씬 코어 : 3.6.2"
의 pom.xml
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>${hibernate.search.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-engine</artifactId>
<version>${hibernate.search.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>3.6.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queries</artifactId>
<version>3.6.2</version>
<scope>runtime</scope>
</dependency>
클래스
@Entity
@SequenceGenerator(name = "sitepagecontent_seq", sequenceName = "SITEPAGECONTENT_SEQ")
@Indexed(index = "SitePageContent")
@FullTextFilterDef(name = "condition1", impl = StatusFilterFactory.class) //Filter factory with parameters
@Analyzer (impl = StandardAnalyzer.class)
@ClassBridge(name = "splitcontentfileupload",
index = Index.YES,
store = Store.YES,
impl = WordDocHandlerBridge.class,
params = @org.hibernate.search.annotations.Parameter(name = "padding", value = " ")
)
@Table(name = "SITE_PAGE_CONTENT")
public class SitePageContent extends BaseObject implements Comparable<SitePageContent> {
// Fields
private static final long serialVersionUID = -7424477214552600300L;
private Long id;
@IndexedEmbedded
private Content content;
@IndexedEmbedded
private SitePage sitePage;
private Long sequence;
Content.java
WordDocHandlerBridge.javapublic class WordDocHandlerBridge implements FieldBridge, ParameterizedBridge {
protected final Log log = LogFactory.getLog(getClass());
public static String paddingProperty = "padding";
private String padding = "";
public void setParameterValues(Map arg0) {
Object padding = arg0.get(paddingProperty);
if (padding != null) {
this.padding = (String) padding;
}
}
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
String fieldValue = "";
SitePageContent sitCont = (SitePageContent) value;
Content cont = sitCont.getContent();
UploadedFile upF = cont.getUploadedFile();
if (upF != null) {
String fieldValue1 = upF.getFileContentType();
if (fieldValue1 == null) {
fieldValue1 = "";
}
byte[] fieldValue2 = upF.getFileContent();
if (fieldValue2 == null) {
fieldValue2 = new byte[0];
}
fieldValue = convertFile2String(fieldValue1, fieldValue2);
} else {
fieldValue = "";
}
Field field = new Field(name, fieldValue, luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector());
field.setBoost(luceneOptions.getBoost());
document.add(field);
}
private String convertFile2String(String type, byte[] content) {
}
나는 "WordDocHandlerBridge.java을"디버깅
@Entity
@SequenceGenerator(name = "content_seq", sequenceName = "CONTENT_SEQ")
@Table(name = "CONTENT")
@VersionSupportModel
public class Content extends BaseObject implements Comparable<Content> {
// ------------------------------ FIELDS ------------------------------
// Fields
private static final long serialVersionUID = 1441591301055742001L;
private Long id;
@IndexedEmbedded
private UploadedFile uploadedFile;
@IndexedEmbedded
private ContentType contentType;
@Field(index = Index.YES, store = Store.YES, analyzer = @Analyzer(impl = StandardAnalyzer.class))
private String title;
private String prevTitle;
@Field(index = Index.YES, store = Store.YES, analyzer = @Analyzer(impl = StandardAnalyzer.class))
private String teaser;
private String prevTeaser;
private String linkedContentType;
private String linkedUrl;
private Boolean linkedContentPopup;
@Field(index = Index.YES, store = Store.YES)
private String status;
private EcommUser createdBy;
private EcommUser modifiedBy;
@Temporal(TemporalType.DATE)
private Date createdDate;
@Temporal(TemporalType.DATE)
private Date modifiedDate;
private String shared;
private String statusTemp;
private Set<Request> requests = new HashSet<Request>(0);
@ContainedIn
private Set<SitePageContent> sitePageContents = new HashSet<SitePageContent>(0);
private Integer version;
private Integer articleId;
private String summary;
@Field(index = Index.YES, store = Store.YES, analyzer = @Analyzer(impl = StandardAnalyzer.class))
private String description;
@Field(index = Index.YES, store = Store.YES, analyzer = @Analyzer(impl = StandardAnalyzer.class))
private String contactName;
@Field(index = Index.YES, store = Store.YES, analyzer = @Analyzer(impl = StandardAnalyzer.class))
private String contactPhone;
@Field(index = Index.YES, store = Store.YES, analyzer = @Analyzer(impl = StandardAnalyzer.class))
private String contactEmail;
@Field(index = Index.YES, store = Store.YES, analyzer = @Analyzer(impl = StandardAnalyzer.class))
private String contactPostalAddress;
, 나는 내 콘텐츠가 필드에 설정하고 문서에 추가 된 것을 볼 수 있어요,하지만 난 검색 할 때 나는 아니다 점점.
참고 : 나를위한 색인을 다시 만드는 독립 실행 형 프로그램이 있습니다. 다시 작성하면 결과를 볼 수 있습니다.
아무쪼록이 문제를 해결할 수 있습니까?