Java 类org.apache.lucene.document.Field.Index 实例源码
项目:arong
文件:DocumentUtil.java
/**
* 将一个pojo类转换为lucene的document文档<br>
* 遵守一一对应原则
*
* @param t
* @return
*/
public static <T> Document pojo2Document(T t) {
Method[] methods = t.getClass().getDeclaredMethods();
Integer methodsLength = methods.length;
String methodName = null;
String menberName = null;
Integer set = null;
Document doc = new Document();
try {
for (int i = 0; i < methodsLength; i++) {
methodName = methods[i].getName();
if (methodName.startsWith("get") || methodName.startsWith("is")) {
set = methodName.startsWith("get") ? 3 : 2;
menberName = Introspector.decapitalize(methodName
.substring(set, methodName.length()));
doc.add(new Field(menberName, String.valueOf(methods[i].invoke(t)), Store.YES, Index.ANALYZED));
}
}
} catch (Exception e) {
e.printStackTrace();
}
return doc;
}
项目:ocms
文件:ContentTableManagerDBImpl.java
public void setIndexProp(ContentTable ct) {
ct.setAllowIndex(1);
Set<ContentField> fields = ct.getContentFieldsSet();
if (fields != null) {
for (ContentField field : fields) {
String indexType = field.getIndexType();
String fieldType = field.getFieldType();
if (!StringUtils.hasText(indexType)
|| indexType.equalsIgnoreCase(Index.NO.toString())) {
if (fieldType.equalsIgnoreCase("varchar")
|| fieldType.equalsIgnoreCase("text")) {
field.setIndexType(Index.TOKENIZED.toString());
}else{
field.setIndexType(Index.UN_TOKENIZED.toString());
}
}
field.setStoreType(Store.COMPRESS.toString());
contentFieldDao.saveContentField(field);
}
}
this.saveContentTable(ct);
}
项目:gitblit
文件:LuceneExecutor.java
/**
* Creates a Lucene document from an issue.
*
* @param issue
* @return a Lucene document
*/
private Document createDocument(IssueModel issue) {
Document doc = new Document();
doc.add(new Field(FIELD_OBJECT_TYPE, SearchObjectType.issue.name(), Store.YES,
Field.Index.NOT_ANALYZED));
doc.add(new Field(FIELD_ISSUE, issue.id, Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_BRANCH, IssueUtils.GB_ISSUES, Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_DATE, DateTools.dateToString(issue.created, Resolution.MINUTE),
Store.YES, Field.Index.NO));
doc.add(new Field(FIELD_AUTHOR, issue.reporter, Store.YES, Index.ANALYZED));
List<String> attachments = new ArrayList<String>();
for (Attachment attachment : issue.getAttachments()) {
attachments.add(attachment.name.toLowerCase());
}
doc.add(new Field(FIELD_ATTACHMENT, StringUtils.flattenStrings(attachments), Store.YES,
Index.ANALYZED));
doc.add(new Field(FIELD_SUMMARY, issue.summary, Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_CONTENT, issue.toString(), Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_LABEL, StringUtils.flattenStrings(issue.getLabels()), Store.YES,
Index.ANALYZED));
return doc;
}
项目:gitblit
文件:LuceneExecutor.java
/**
* Creates a Lucene document for a commit
*
* @param commit
* @param tags
* @return a Lucene document
*/
private Document createDocument(RevCommit commit, List<String> tags) {
Document doc = new Document();
doc.add(new Field(FIELD_OBJECT_TYPE, SearchObjectType.commit.name(), Store.YES,
Index.NOT_ANALYZED));
doc.add(new Field(FIELD_COMMIT, commit.getName(), Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_DATE, DateTools.timeToString(commit.getCommitTime() * 1000L,
Resolution.MINUTE), Store.YES, Index.NO));
doc.add(new Field(FIELD_AUTHOR, getAuthor(commit), Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_COMMITTER, getCommitter(commit), Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_SUMMARY, commit.getShortMessage(), Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_CONTENT, commit.getFullMessage(), Store.YES, Index.ANALYZED));
if (!ArrayUtils.isEmpty(tags)) {
doc.add(new Field(FIELD_TAG, StringUtils.flattenStrings(tags), Store.YES, Index.ANALYZED));
}
return doc;
}
项目:IRCBlit
文件:LuceneExecutor.java
/**
* Creates a Lucene document from an issue.
*
* @param issue
* @return a Lucene document
*/
private Document createDocument(IssueModel issue) {
Document doc = new Document();
doc.add(new Field(FIELD_OBJECT_TYPE, SearchObjectType.issue.name(), Store.YES,
Field.Index.NOT_ANALYZED));
doc.add(new Field(FIELD_ISSUE, issue.id, Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_BRANCH, IssueUtils.GB_ISSUES, Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_DATE, DateTools.dateToString(issue.created, Resolution.MINUTE),
Store.YES, Field.Index.NO));
doc.add(new Field(FIELD_AUTHOR, issue.reporter, Store.YES, Index.ANALYZED));
List<String> attachments = new ArrayList<String>();
for (Attachment attachment : issue.getAttachments()) {
attachments.add(attachment.name.toLowerCase());
}
doc.add(new Field(FIELD_ATTACHMENT, StringUtils.flattenStrings(attachments), Store.YES,
Index.ANALYZED));
doc.add(new Field(FIELD_SUMMARY, issue.summary, Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_CONTENT, issue.toString(), Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_LABEL, StringUtils.flattenStrings(issue.getLabels()), Store.YES,
Index.ANALYZED));
return doc;
}
项目:IRCBlit
文件:LuceneExecutor.java
/**
* Creates a Lucene document for a commit
*
* @param commit
* @param tags
* @return a Lucene document
*/
private Document createDocument(RevCommit commit, List<String> tags) {
Document doc = new Document();
doc.add(new Field(FIELD_OBJECT_TYPE, SearchObjectType.commit.name(), Store.YES,
Index.NOT_ANALYZED));
doc.add(new Field(FIELD_COMMIT, commit.getName(), Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_DATE, DateTools.timeToString(commit.getCommitTime() * 1000L,
Resolution.MINUTE), Store.YES, Index.NO));
doc.add(new Field(FIELD_AUTHOR, getAuthor(commit), Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_COMMITTER, getCommitter(commit), Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_SUMMARY, commit.getShortMessage(), Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_CONTENT, commit.getFullMessage(), Store.YES, Index.ANALYZED));
if (!ArrayUtils.isEmpty(tags)) {
doc.add(new Field(FIELD_TAG, StringUtils.flattenStrings(tags), Store.YES, Index.ANALYZED));
}
return doc;
}
项目:OpenCyclos
文件:DocumentBuilder.java
/**
* Adds an string field, which may be analyzer or not
*/
public DocumentBuilder add(final String name, final String value, final boolean analyzed) {
if (StringUtils.isNotEmpty(value)) {
final Field field = new Field(name, value, Store.YES, analyzed ? Index.ANALYZED : Index.NOT_ANALYZED);
document.add(field);
}
return this;
}
项目:webdsl
文件:WebDSLDynamicFieldBridge.java
@Override
public void set(
String name, Object value, Document document, LuceneOptions luceneOptions) {
for(DynamicSearchField dsf : ( (DynamicSearchFields) value).getDynamicSearchFields_()){
document.add( new Field( dsf.fieldName, dsf.fieldValue, Store.NO,
Index.NOT_ANALYZED, luceneOptions.getTermVector() ) );
}
}
项目:community-edition-old
文件:AlfrescoSolrDataModel.java
/**
*
*/
public NonDictionaryField(String name, Store store, Index index, TermVector termVector, boolean multiValued)
{
this.name = name;
this.store = store;
this.index = index;
this.termVector = termVector;
this.multiValued = multiValued;
}
项目:tool
文件:NamedElementIndexAccess.java
@Override
protected Document toDocument(final Element e) {
final Document d = super.toDocument(e);
d.add(new Field(FIELD_NAME, compact(defaultString(getName(e), StringUtils.EMPTY)), Store.YES, Index.ANALYZED));
d.add(new Field(FIELD_COMMENTS, getComments(e), Store.YES, Index.ANALYZED));
return d;
}
项目:tool
文件:ElementIndexAccess.java
protected Document toDocument(final Element e) {
final Document d = new Document();
final URI uri = EcoreUtil.getURI(e);
d.add(new Field(FIELD_RESOURCE, uri.lastSegment(), Store.YES, Index.NOT_ANALYZED));
d.add(new Field(FIELD_ID, uri.fragment(), Store.YES, Index.NOT_ANALYZED));
return d;
}
项目:NIEM-Modeling-Tool
文件:NamedElementIndexAccess.java
@Override
protected Document toDocument(final Element e) {
final Document d = super.toDocument(e);
d.add(new Field(FIELD_NAME, compact(defaultString(getName(e), StringUtils.EMPTY)), Store.YES, Index.ANALYZED));
d.add(new Field(FIELD_COMMENTS, getComments(e), Store.YES, Index.ANALYZED));
return d;
}
项目:NIEM-Modeling-Tool
文件:ElementIndexAccess.java
protected Document toDocument(final Element e) {
final Document d = new Document();
final URI uri = EcoreUtil.getURI(e);
d.add(new Field(FIELD_RESOURCE, uri.lastSegment(), Store.YES, Index.NOT_ANALYZED));
d.add(new Field(FIELD_ID, uri.fragment(), Store.YES, Index.NOT_ANALYZED));
return d;
}
项目:neo4j-mobile-android
文件:IndexType.java
Fieldable instantiateField( String key, Object value, Index analyzed )
{
Fieldable field = null;
if ( value instanceof Number )
{
Number number = (Number) value;
NumericField numberField = new NumericField( key, Store.YES, true );
if ( value instanceof Long )
{
numberField.setLongValue( number.longValue() );
}
else if ( value instanceof Float )
{
numberField.setFloatValue( number.floatValue() );
}
else if ( value instanceof Double )
{
numberField.setDoubleValue( number.doubleValue() );
}
else
{
numberField.setIntValue( number.intValue() );
}
field = numberField;
}
else
{
field = new Field( key, value.toString(), Store.YES, analyzed );
}
return field;
}
项目:neo4j-mobile-android
文件:IndexType.java
static Document newBaseDocument( long entityId )
{
Document doc = new Document();
doc.add( new Field( LuceneIndex.KEY_DOC_ID, "" + entityId, Store.YES,
Index.NOT_ANALYZED ) );
return doc;
}
项目:open-cyclos
文件:DocumentBuilder.java
/**
* Adds an string field, which may be analyzer or not
*/
public DocumentBuilder add(final String name, final String value, final boolean analyzed) {
if (StringUtils.isNotEmpty(value)) {
final Field field = new Field(name, value, Store.YES, analyzed ? Index.ANALYZED : Index.NOT_ANALYZED);
document.add(field);
}
return this;
}
项目:ridire-cpi
文件:AsyncSketchCreator.java
private void addDocument(Map<String, SketchResult> sr, String lemma,
IndexWriter indexWriter, String sketch, String type,
String functional, String semantic, String goodFor)
throws CorruptIndexException, IOException {
Document d = new Document();
List<SketchResult> orderedSketchResults = this
.getOrderedSketchResults(sr.values());
StringBuffer sb = new StringBuffer();
long fA = 0L;
for (SketchResult r : orderedSketchResults) {
fA = r.getfA();
sb.append(r.getCollocata() + "\t" + r.getfAB() + "\t"
+ r.getScore() + "\t" + fA + "\t" + r.getfB() + "\t" + "\n");
}
d.add(new Field("overallfrequency", fA + "", Store.YES, Index.NO));
d.add(new Field("tabella", sb.toString(), Store.YES, Index.NO));
d.add(new Field("lemma", lemma, Store.NO, Index.NOT_ANALYZED_NO_NORMS));
d.add(new Field("sketch", sketch, Field.Store.YES,
Index.NOT_ANALYZED_NO_NORMS));
d.add(new Field("goodFor", goodFor, Field.Store.YES,
Index.NOT_ANALYZED_NO_NORMS));
d.add(new Field("type", type, Field.Store.NO,
Index.NOT_ANALYZED_NO_NORMS));
if (functional != null) {
d.add(new Field("functional", functional, Field.Store.NO,
Index.NOT_ANALYZED_NO_NORMS));
}
if (semantic != null) {
d.add(new Field("semantic", semantic, Field.Store.NO,
Index.NOT_ANALYZED_NO_NORMS));
}
if (functional == null && semantic == null) {
d.add(new Field("allcorpora", "yes", Field.Store.NO,
Index.NOT_ANALYZED_NO_NORMS));
}
indexWriter.addDocument(d);
indexWriter.commit();
}
项目:alfresco-repository
文件:ReferenceCountingReadOnlyIndexReaderFactory.java
public Field get(int n, FieldSelector fieldSelector) throws IOException
{
return new Field(fieldName, getStringValue(n, fieldName), Store.NO, Index.UN_TOKENIZED);
}
项目:neo4j-lucene5-index
文件:LuceneIndexWriterTest.java
private Document newDocument()
{
Document doc = new Document();
doc.add( new Field( "test", "test", Store.NO, Index.NOT_ANALYZED ) );
return doc;
}
项目:community-edition-old
文件:ReferenceCountingReadOnlyIndexReaderFactory.java
public Field get(int n, FieldSelector fieldSelector) throws IOException
{
return new Field(fieldName, getStringValue(n, fieldName), Store.NO, Index.UN_TOKENIZED);
}
项目:community-edition-old
文件:AlfrescoSolrDataModel.java
private static void addNonDictionaryField(String name, Store store, Index index, TermVector termVector, boolean multiValued)
{
nonDictionaryFields.put(name, new NonDictionaryField(name, store, index, termVector, multiValued));
}
项目:community-edition-old
文件:AlfrescoSolrDataModel.java
private static void addAdditionalContentField(String name, Store store, Index index, TermVector termVector, boolean multiValued)
{
additionalContentFields.put(name, new NonDictionaryField(name, store, index, termVector, multiValued));
}
项目:community-edition-old
文件:AlfrescoSolrDataModel.java
private static void addAdditionalTextField(String name, Store store, Index index, TermVector termVector, boolean multiValued)
{
additionalTextFields.put(name, new NonDictionaryField(name, store, index, termVector, multiValued));
}
项目:community-edition-old
文件:AlfrescoSolrDataModel.java
private static void addAdditionalMlTextField(String name, Store store, Index index, TermVector termVector, boolean multiValued)
{
additionalMlTextFields.put(name, new NonDictionaryField(name, store, index, termVector, multiValued));
}
项目:community-edition-old
文件:AlfrescoSolrDataModel.java
/**
* @param field
* @return
*/
public Index getFieldIndex(SchemaField field)
{
PropertyDefinition propertyDefinition = getPropertyDefinition(field.getName());
if (propertyDefinition != null)
{
if (propertyDefinition.isIndexed())
{
switch (propertyDefinition.getIndexTokenisationMode())
{
case TRUE:
case BOTH:
default:
return Index.ANALYZED;
case FALSE:
return Index.NOT_ANALYZED;
}
}
else
{
return Field.Index.NO;
}
}
NonDictionaryField nonDDField = nonDictionaryFields.get(field.getName());
if (nonDDField != null)
{
return nonDDField.index;
}
for (String additionalContentFieldEnding : additionalContentFields.keySet())
{
if (field.getName().endsWith(additionalContentFieldEnding)
&& (getPropertyDefinition(field.getName().substring(0, (field.getName().length() - additionalContentFieldEnding.length()))) != null))
{
return additionalContentFields.get(additionalContentFieldEnding).index;
}
}
for (String additionalTextFieldEnding : additionalTextFields.keySet())
{
if (field.getName().endsWith(additionalTextFieldEnding)
&& (getPropertyDefinition(field.getName().substring(0, (field.getName().length() - additionalTextFieldEnding.length()))) != null))
{
return additionalTextFields.get(additionalTextFieldEnding).index;
}
}
for (String additionalMlTextFieldEnding : additionalMlTextFields.keySet())
{
if (field.getName().endsWith(additionalMlTextFieldEnding)
&& (getPropertyDefinition(field.getName().substring(0, (field.getName().length() - additionalMlTextFieldEnding.length()))) != null))
{
return additionalMlTextFields.get(additionalMlTextFieldEnding).index;
}
}
return Index.ANALYZED;
}
项目:community-edition-old
文件:AlfrescoDataType.java
@Override
protected Index getFieldIndex(SchemaField field, String internalVal)
{
return AlfrescoSolrDataModel.getInstance(id).getFieldIndex(field);
}
项目:tool
文件:PropertyIndexAccess.java
@Override
protected Document toDocument(final Element e) {
final Document d = super.toDocument(e);
d.add(new Field(FIELD_SUBSTITUTION_GROUP, getSubsettedProperties((Property) e), Store.YES, Index.NOT_ANALYZED));
return d;
}
项目:tool
文件:PackageIndexAccess.java
@Override
protected Document toDocument(final Element e) {
final Document d = super.toDocument(e);
d.add(new Field(FIELD_TARGET_NAMESPACE, getTargetNamespace(e), Store.YES, Index.NOT_ANALYZED));
return d;
}
项目:NIEM-Modeling-Tool
文件:PropertyIndexAccess.java
@Override
protected Document toDocument(final Element e) {
final Document d = super.toDocument(e);
d.add(new Field(FIELD_SUBSTITUTION_GROUP, getSubsettedProperties((Property) e), Store.YES, Index.NOT_ANALYZED));
return d;
}
项目:NIEM-Modeling-Tool
文件:PackageIndexAccess.java
@Override
protected Document toDocument(final Element e) {
final Document d = super.toDocument(e);
d.add(new Field(FIELD_TARGET_NAMESPACE, getTargetNamespace(e), Store.YES, Index.NOT_ANALYZED));
return d;
}
项目:neo4j-mobile-android
文件:IndexType.java
@Override
public void addToDocument( Document document, String key, Object value )
{
document.add( instantiateField( key, value, Index.NOT_ANALYZED ) );
}
项目:neo4j-mobile-android
文件:IndexType.java
@Override
public void addToDocument( Document document, String key, Object value )
{
document.add( new Field( exactKey( key ), value.toString(), Store.YES, Index.NOT_ANALYZED ) );
document.add( instantiateField( key, value, Index.ANALYZED ) );
}