gkatoch opened a new issue, #858: URL: https://github.com/apache/lucenenet/issues/858
Consider the following enum: ``` [Flags] public enum Colors { None=0, Red=0x1, Blue=0x2, Green=0x4, Comination1 = 0x3f, Yellow = 0x40, Orange= 0x80, Violet = 0x100, Combination2 = 0xFC0, All = 0xFFF } ``` These are contained in a class like: ``` public class Test { public string Name {get;set;} public Colors Color {get;set;} } ``` The main class saving/retrieving these: ``` static class Program { private RAMDirectory _directory; private const LuceneVersion Lv = LuceneVersion.LUCENE_48; public static void main(string[] args) { var temp = new List<Test>(); temp.Add(new Test{ Name= "ABC", Color = Colors.Red}; temp.Add(new Test{ Name= "DEF", Color = Colors.Combination2 }; temp.Add(new Test{ Name= "ABC", Color = Colors.All}; temp.Add(new Test{ Name= "ABC", Color = Colors.Combination1 }; _directory = new RAMDirectory(); var analyzer= new StandardAnalyzer(Lv); //WRITE DATA var config = new IndexWriterConfig(Lv, analyzer); var writer = new IndexWriter(_directory, config); var nameField = new TextField("Name", "", Field.Store.YES); var colorField = new TextField("Color", "", Field.Store.YES); foreach(var val in temp) { var doc = new Document {nameField , colorField }; nameField.SetStringValue(val.Name); colorField.SetStringValue(val.Color); writer.AddDocument(doc); } writer.Commit(); //READ BACK var search = Console.ReadLine(); var colorValue = Console.ReadLine(); var reader = DirectoryReader.Open(_directory); var searcher = new IndexSearcher(reader); var analyzer = new StandardAnalyzer(Lv); var parser= new MultiFieldQueryParser(Lv, new string[]{"Name", "Color"}, analyzer); var query = parser.Parse(search.Trim()); var filter = new BooleanFilter(); filter.Add(new FilterClause(new TermFilter(new Term( "Color",colorValue ))), Occur.SHOULD)); var result = searcher.Search(query, filter, 100).ScoreDocs; } } ``` The above code works fine when individual colors like Red, Green are specified . However for enum values like `Combination1`, `Combination2 `and `All `this does not get all matching Colors. This is since I add Flag values as string and there isn't a string match available for the items: `Red is valid for Combination1 enum value but not valid for a string comparison` Is there a better way to do this where I can use `HasFlag` method in filter to check matching bits? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@lucenenet.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org