Is it Possible to get all Product with TextOption field or MediaPointerFile have any values?

How to get all Product with a specific TextOption field or MediaPointerFile field having any values using search Query(using lucene)?
I need to list down all product with document and TextOption values as table.
Some thing like this,
Product Name | File _____ | TextOption value1 | TextOption value2
Product1 _____ | filename__ | Yes ____________ | No
product2 _____ | filename __ | No ____________ | Yes


I think you should be able to use a basic search, something like this (Make sure your field is added to the index, CanBeGridFilter)

 var searchRequest = new QueryRequest(_languageService.Get(CultureInfo.CurrentCulture).SystemId, ProductCatalogSearchDomains.Products, Solution.Instance.SystemToken)
                Paging = new Paging(pageIndex, 100000)
            searchRequest.FilterTags.Add(new Tag("TextOptionId".GetFieldDefinitionForProducts().GetTagName("Add culture info, if needed"), "ValueYouAreSearchingFor"));
            searchRequest.FilterTags.Add(new Tag(TagNames.ChannelSystemId, channel.SystemId));
            searchRequest.Sortings.Add(new Sorting(TagNames.ArticleNumber, SortDirection.Descending, SortingFieldType.String));
            var response = Solution.Instance.SearchService.Search(searchRequest);

Hi @Ericsj11
I Don’t want to search for a specific value, I just want to get all product that have any value specified in TextOption field or MediaPointerFile field of base product .

Aha, sorry don’t know about that. It’s possible with dataservice, but that calls the database so it’s not good to use for customers.

You could add a true/false value in the index with the IIndexingProviderPreProcessor by checking those values in PreProcessDocument. And then search the true/false value.
It might not be the best solution if “any” searches exists, but it’s a valid solution :sweat_smile:

It’s not possible to search for any value, and Lucene doesn’t index null values. So you would have to do something like Eric suggests: use a dummy value that you index if no value is set and then you can do a search excluding all results with the dummy value.

The other option is DataService which supports many different operators, but you need to build a cache if the query is accessible from the public site to avoid performance issues.