You can do this, Lucene will let you, but it's typically a bad idea for search relevance because some documents will return only if you search for precisely the same whole token, others if you search for an analyzed token, giving the user a broken experience.
Mike McCandless http://blog.mikemccandless.com On Fri, Nov 18, 2016 at 6:00 AM, Kumaran Ramasubramanian <kums....@gmail.com> wrote: > Hi All, > > Can anyone say, is it advisable to have index with both analyzed and > not_analyzed values in one field? > > Use case: i have custom fields in my product which can be configured > differently ( ANALYZED and NOT_ANALYZED ) in different modules > > -- > Kumaran R > > > > > > On Wed, Oct 26, 2016 at 12:07 AM, Kumaran Ramasubramanian < > kums....@gmail.com> wrote: > >> >> >> Hi All, >> >> i have indexed 4 documents in an index where BANKNAME field is analyzed >> in two documents and it is not_analyzed in another two documents. i have >> mentioned search cases below where i am able to search using both analyzed >> ( using classic analyzer ) and not_analyzed ( using keyword analyzer ) >> terms. But, is it right to have index with both analyzed and not_analyzed >> values in a field? >> >> >> >> >> output: >> >> >> BANKNAME field of these two documents is analyzed >> >> using classic analyzer >> query : BANKNAME:"swiss bank" >> total hits:2 >> >> DocId:0 DocScore:1.6096026 >> [stored,indexed,tokenized<BANKNAME:swiss bank>, >> stored,indexed,tokenized<PLACENAME:swissland>, >> stored,indexed,tokenized,omitNorms,indexOptions=DOCS_ONLY<company:goog>] >> >> DocId:2 DocScore:1.6096026 >> [stored,indexed,tokenized<BANKNAME:swiss bank>, >> stored,indexed,tokenized<PLACENAME:swissland>, >> stored,indexed,tokenized,omitNorms,indexOptions=DOCS_ONLY<company:goog>] >> >> >> >> >> >> BANKNAME field of these two documents is not analyzed >> >> using keyword analyzer >> rrsk query : BANKNAME:swiss bank >> total hits:2 >> >> DocId:1 DocScore:1.287682 >> [stored,indexed,tokenized<BANKNAME:swiss bank>, >> stored,indexed,tokenized<PLACENAME:swiss>, stored,indexed,tokenized,omitN >> orms,indexOptions=DOCS_ONLY<company:goog>] >> >> DocId:3 DocScore:1.287682 >> [stored,indexed,tokenized<BANKNAME:swiss bank>, >> stored,indexed,tokenized<PLACENAME:swiss>, stored,indexed,tokenized,omitN >> orms,indexOptions=DOCS_ONLY<company:goog>] >> >> >> >> >> >> >> -- >> Kumaran R >> >> >> >> >> >> >> >> >> >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org