Hi Shawn, Thanks for reply. i am also worried wither performance. I will check if there is another way to design the documents in case of parent and child relationship.
Regards, Anil On 27 May 2016 at 12:39, Shawn Heisey <apa...@elyograg.org> wrote: > On 5/26/2016 11:13 PM, Anil wrote: > > We have status text field in our solr document and it is optional. > > search query status: !Closed returning documents with no status as > > well. how to get only documents having status and it is !Closed ? one > > way is status:* AND status:!Closed . any other way ? Thanks > > If you use status:* then you are doing a wildcard query. If the status > field has a large number of unique values, this will be VERY slow. > Avoid wildcard queries unless they are the only way to accomplish what > you need. > > If the status field has more than a few possible values, the most > compact way to do this query efficiently would be: > > status:[* TO *]-status:Closed > > This could be written as: > > status:[* TO *] AND NOT status:Closed > > See this article about why this may not be the best way to write queries: > > https://lucidworks.com/blog/2011/12/28/why-not-and-or-and-not/ > > The [] syntax is a range query. By starting and ending the range with > the * character, it means "all documents where status has a value". > > Thanks, > Shawn > >