File idxDir = new File(args[2]);
JSONObject schemaData = SenseiServerBuilder.loadSchema(confDir);
SenseiSchema schema = SenseiSchema.build(schemaData);
DefaultJsonSchemaInterpreter defaultInterpreter = new DefaultJsonSchemaInterpreter(schema, new PluggableSearchEngineManager() {
@Override
public Set<String> getFieldNames() {
return new HashSet<String>();
}
});
FileReader freader = new FileReader(dataFile);
BufferedReader br = new BufferedReader(freader);
IndexWriter idxWriter = new IndexWriter(SimpleFSDirectory.open(idxDir),new StandardAnalyzer(Version.LUCENE_CURRENT),MaxFieldLength.UNLIMITED);
while(true){
String line = br.readLine();
if (line==null) break;
JSONObject obj = new FastJSONObject(line);
ZoieIndexable indexable = defaultInterpreter.convertAndInterpret(obj);
IndexingReq[] idxReqs = indexable.buildIndexingReqs();
for (IndexingReq req : idxReqs){
Document doc = req.getDocument();
idxWriter.addDocument(doc);
}