문제

If I have the following class, would I be adding both fields to the same name Lucene index or would one overwrite the other?

public User {

    @Field(name="name",store = Store.YES)
    public String getDecoratedName() {
        return name + " foobar";
    }

    @Field(store = Store.YES)
    public String getName() {
        return name;
    }

}
도움이 되었습니까?

해결책

The underlying data structure in Lucene is a so called Document which is basically a list of Fieldables. A Fieldable is basically a key/value pair. You can have multiple fields with the same key.

So to answer your question, in your scenario there will be two fields both with the same key ('name'). The value differs of course.

다른 팁

You would be adding both. Which implies a query on field "name" would match if either of the two matches. You probably want to keep them separate to have the flexibility of picking which one you want to target during a query: you can easily target both if needed.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top