Skip to content

Instantly share code, notes, and snippets.

@need4spd
Last active October 13, 2015 06:27
Show Gist options
  • Save need4spd/4152886 to your computer and use it in GitHub Desktop.
Save need4spd/4152886 to your computer and use it in GitHub Desktop.
crescent collections.xml 설정 설명
<?xml version="1.0" encoding="UTF-8"?>
<collections>
<collection name="sample">
<analyzer>com.tistory.devyongsik.analyzer.KoreanAnalyzer</analyzer>
<indexingDirectory>/Users/need4spd/Programming/Java/crescent_index/sample</indexingDirectory>
<!-- indexingDirectory>/data1/lucene_index/sample</indexingDirectory -->
<!-- indexingDirectory>/Users/need4spd/Programming/Java/workspace/crescent/test/crescent_index/sample</indexingDirectory -->
<fields>
<!-- type : string, long, int -->
<field name="board_id" store="true" index="true" type="long" analyze="false" termposition="false" termoffset="false" />
<field name="title" store="true" index="true" type="string" analyze="true" boost="2.0" />
<field name="dscr" store="true" index="true" type="string" analyze="true" must="true" termvector="true" />
<field name="creuser" store="true" index="false" type="string" analyze="false" />
</fields>
<defaultSearchFields>
<defaultSearchField name="title" />
<defaultSearchField name="dscr" />
</defaultSearchFields>
<sortFields>
<sortField source="title" dest="title_sort" />
<sortField source="board_id" dest="board_id_sort" />
</sortFields>
</collection>
<collection name="sample_wiki">
<analyzer>com.tistory.devyongsik.analyzer.KoreanAnalyzer</analyzer>
<indexingDirectory>/Users/need4spd/Programming/Java/crescent_index/sample_wiki</indexingDirectory>
<!-- indexingDirectory>/data1/lucene_index/glider_wiki</indexingDirectory -->
<!-- indexingDirectory>/Users/need4spd/Programming/Java/workspace/crescent/test/crescent_index/glider_wiki</indexingDirectory -->
<fields>
<!-- type : string, long, int -->
<field name="wiki_idx" store="true" index="true" type="long" analyze="false" />
<field name="space_idx" store="true" index="true" type="long" analyze="false" />
<field name="wiki_text" store="true" index="true" type="string" analyze="true" must="true" termvector="true" />
<field name="wiki_title" store="true" index="true" type="string" analyze="true" must="true" boost="2.0" />
<field name="ins_user" store="true" index="true" type="string" analyze="false" />
<field name="ins_date" store="true" index="true" type="long" analyze="false" />
</fields>
<defaultSearchFields>
<defaultSearchField name="wiki_title" />
<defaultSearchField name="wiki_text" />
</defaultSearchFields>
<sortFields>
<sortField source="ins_date" dest="ins_date_sort" />
<sortField source="wiki_idx" dest="wiki_idx_sort" />
</sortFields>
</collection>
</collections>
package com.tistory.devyongsik.domain;
import java.util.List;
import java.util.Map;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamOmitField;
@XStreamAlias("collection")
public class CrescentCollection {
private String analyzer;
@XStreamAsAttribute
private String name;
private String indexingDirectory;
@XStreamOmitField
private Map crescentFieldByName;
private List fields;
private List defaultSearchFields;
private List sortFields;
public String getAnalyzer() {
return analyzer;
}
}
package com.tistory.devyongsik.domain;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.SortField;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
@XStreamAlias("field")
public class CrescentCollectionField implements Cloneable {
@XStreamAsAttribute
private String name;
@XStreamAsAttribute
private boolean store;
@XStreamAsAttribute
private boolean index;
@XStreamAsAttribute
private String type;
@XStreamAsAttribute
private boolean analyze;
@XStreamAsAttribute
private boolean termposition;
@XStreamAsAttribute
private boolean termoffset;
@XStreamAsAttribute
private float boost;
@XStreamAsAttribute
private boolean must;
@XStreamAsAttribute
private boolean termvector;
}
package com.tistory.devyongsik.domain;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamImplicit;
import com.thoughtworks.xstream.annotations.XStreamOmitField;
@XStreamAlias("collections")
public class CrescentCollections {
@XStreamImplicit(itemFieldName="collection")
private List crescentCollections = null;
@XStreamOmitField
private Map crescentCollectionsMap = null;
public Map getCrescentCollectionsMap() {
lazyLoadMap();
return crescentCollectionsMap;
}
public void setCrescentCollectionsMap(
Map crescentCollectionsMap) {
this.crescentCollectionsMap = crescentCollectionsMap;
}
public List getCrescentCollections() {
return crescentCollections;
}
public void setCrescentCollections(List crescentCollections) {
this.crescentCollections = crescentCollections;
}
@Override
public String toString() {
return "CrescentCollections [crescentCollections="
+ crescentCollections + "]";
}
}
package com.tistory.devyongsik.domain;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
@XStreamAlias("defaultSearchField")
public class CrescentDefaultSearchField {
@XStreamAsAttribute
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "CrescentDefaultSearchField [name=" + name + "]";
}
}
XStream stream = new XStream();
stream.processAnnotations(CrescentCollections.class);
//stream.alias( "collections", CrescentCollections.class );
//stream.addImplicitCollection( CrescentCollections.class, "crescentCollections" );
ResourceLoader resourceLoader = new ResourceLoader();
InputStream inputStream = resourceLoader.openResource("경로");
CrescentCollections crescentCollections = (CrescentCollections)stream.fromXML(inputStream);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment