Thanks for your advice. If I want to sort some field (for example name is "TITLE") and It must be Analyzed.
Then Do I have to make two field that one is ANALYZED and the other is NOT_ANALYZED like this? document.add(new Field("TITLE", value, Field.Store.NO. Field.Index.ANALYZED) document.add(new Field("TITLE_FOR_SORT", value, Field.Store.NO, Field.Index.NOT_ANALYZED) - Jang. 09. 1. 6, Koji Sekiguchi <k...@r.email.ne.jp>님이 작성: > > See Sort class javadoc: > > http://hudson.zones.apache.org/hudson/job/Lucene-trunk/javadoc/org/apache/lucene/search/Sort.html > > It says: > > The fields used to determine sort order must be carefully chosen. > Documents must contain a single term in such a field, and the value of > the term should indicate the document's relative position in a given > sort order. The field must be indexed, but should not be tokenized, and > does not need to be stored (unless you happen to want it back with the > rest of your document data). In other words: > > document.add (new Field ("byNumber", Integer.toString(x), > Field.Store.NO, Field.Index.NOT_ANALYZED)); > > Koji > > 장용석 wrote: > > Hi. > > > > I want to test sorting when search so I was created simple index like > this. > > > > String[] samples = {"duck dog","first dog","grammar dog","come > dog","basic > > dog","intro dog","lipton dog","search dog","servlet dog","jan dog"}; > > Directory dir = FSDirectory.getDirectory(path); > > IndexWriter writer = new IndexWriter(dir,new > GSKoreanAnalyzer(true),true); > > Document document = null; > > > > for(int i = 0; i < samples.length; i++) { > > document = new Document(); > > Field field = new > > > Field("name",samples[i],Field.Store.YES,Field.Index.ANALYZED,Field.TermVector.WITH_POSITIONS_OFFSETS); > > document.add(field); > > > > writer.addDocument(document); > > } > > writer.optimize(); > > writer.close(); > > and I did create sample code (use Sort and TopFieldDocs). > > > > but It didn't work and throw Exception "there are more terms than > documents > > in field "name", but it's impossible to sort on tokenized fields" > > > > What is this mean? I was searched about this issue in google and lucene > > java-wiki but I can't find. > > > > Is my code is wrong? > > > > If I had mistake, point to me please. > > > > Thanks. > > > > - Jang. > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > > -- DEV용식 http://devyongsik.tistory.com