Is it possible to force solr show all facet values for the field with an enum type?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Is it possible to force solr show all facet values for the field with an enum type?

Arvydas Silanskas
Hello,
I have an enum solr fieldtype. When I do a facet search, I want that all
the enum values appear in the facet -- and setting field.mincount = 0 is
not enough. It only works, if there exist a document with the matching
value for the field, but it was filtered out by current query (and then I'm
returned that facet value with the count 0). But can I make it to also
return the values that literally none of the documents in the index have?
The values, that only appear in the enum declaration xml.
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to force solr show all facet values for the field with an enum type?

Erick Erickson
So really the results you want are q=*:*&facet.field=enumField right?
You could fire that query in parallel and combine the two in your app,
perhaps caching the result if the index isn't changing very rapidly.

Facets were designed with the idea that they'd only count for docs
that were hits, so there's no built-in way to do what you want. Which, BTW,
could be _very_ expensive in the general case. The query would
have to count up, say, the hits for 100M documents...

Best,
Erick

On Sat, Jan 5, 2019 at 1:53 AM Arvydas Silanskas
<[hidden email]> wrote:
>
> Hello,
> I have an enum solr fieldtype. When I do a facet search, I want that all
> the enum values appear in the facet -- and setting field.mincount = 0 is
> not enough. It only works, if there exist a document with the matching
> value for the field, but it was filtered out by current query (and then I'm
> returned that facet value with the count 0). But can I make it to also
> return the values that literally none of the documents in the index have?
> The values, that only appear in the enum declaration xml.
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to force solr show all facet values for the field with an enum type?

Arvydas Silanskas
Thanks for your reply.

No, not exactly what I want.

Consider I have enum defined as

<enum name="Enum">
    <value>A</value>
    <value>B</value>
</enum>

and correspondingly I have defined a fieldtype "enumType" that uses this
enum, and a field "enumfield" that is of type "enumType". Consider my index
is like this:

[
      {
        "name_s":"Doc 1",
        "enumfield":"A",
        "user_s":"Foo",
        "id":"2ebc0754-e7d8-405e-9962-99c6cd1d9275",
        "_version_":1621850725207244800},
      {
        "name_s":"Doc 2",
        "user_s":"Bar",
        "id":"0536827a-703a-456e-9087-71b85b63c58b",
        "_version_":1621850725397037056}]

notice how there are no documents that have "enumfield":"B".
Now, if I execute query
"facet.field=enumfield&facet=on&fq=user_s:Bar&indent=on&q=*:*&wt=json",
my facet response's fields look like this:

"facet_fields":{
      "enumfield":[
        "A",0]}

There is no "B" key -- and that's my problem. It tells me about other
facet values if they're filtered out by fq, but it tells me nothing
about facet values that aren't present in any doc.

My question is how to force the response to be
"facet_fields":{
      "enumfield":[
        "A",0,
        "B", 0]}


2019-01-05, št, 19:42 Erick Erickson <[hidden email]> rašė:

> So really the results you want are q=*:*&facet.field=enumField right?
> You could fire that query in parallel and combine the two in your app,
> perhaps caching the result if the index isn't changing very rapidly.
>
> Facets were designed with the idea that they'd only count for docs
> that were hits, so there's no built-in way to do what you want. Which, BTW,
> could be _very_ expensive in the general case. The query would
> have to count up, say, the hits for 100M documents...
>
> Best,
> Erick
>
> On Sat, Jan 5, 2019 at 1:53 AM Arvydas Silanskas
> <[hidden email]> wrote:
> >
> > Hello,
> > I have an enum solr fieldtype. When I do a facet search, I want that all
> > the enum values appear in the facet -- and setting field.mincount = 0 is
> > not enough. It only works, if there exist a document with the matching
> > value for the field, but it was filtered out by current query (and then
> I'm
> > returned that facet value with the count 0). But can I make it to also
> > return the values that literally none of the documents in the index have?
> > The values, that only appear in the enum declaration xml.
>
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to force solr show all facet values for the field with an enum type?

Mikhail Khludnev-2
In reply to this post by Arvydas Silanskas
Hello,
On Sat, Jan 5, 2019 at 12:53 PM Arvydas Silanskas <
[hidden email]> wrote:

> But can I make it to also
> return the values that literally none of the documents in the index have?
>
No.

--
Sincerely yours
Mikhail Khludnev
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to force solr show all facet values for the field with an enum type?

David Santamauro
In reply to this post by Arvydas Silanskas
Seeing that the field is an enumeration, couldn't you just use a set of facet.query(s)?

  ?q=*:*
  &fq=user_s:Bar
  &facet=true
  &facet.query=enumfield:A
  &facet.query=enumfield:B
  &facet.mincount=0

//

On 1/5/19, 3:01 PM, "Arvydas Silanskas" <[hidden email]> wrote:

    Thanks for your reply.
   
    No, not exactly what I want.
   
    Consider I have enum defined as
   
    <enum name="Enum">
        <value>A</value>
        <value>B</value>
    </enum>
   
    and correspondingly I have defined a fieldtype "enumType" that uses this
    enum, and a field "enumfield" that is of type "enumType". Consider my index
    is like this:
   
    [
          {
            "name_s":"Doc 1",
            "enumfield":"A",
            "user_s":"Foo",
            "id":"2ebc0754-e7d8-405e-9962-99c6cd1d9275",
            "_version_":1621850725207244800},
          {
            "name_s":"Doc 2",
            "user_s":"Bar",
            "id":"0536827a-703a-456e-9087-71b85b63c58b",
            "_version_":1621850725397037056}]
   
    notice how there are no documents that have "enumfield":"B".
    Now, if I execute query
    "facet.field=enumfield&facet=on&fq=user_s:Bar&indent=on&q=*:*&wt=json",
    my facet response's fields look like this:
   
    "facet_fields":{
          "enumfield":[
            "A",0]}
   
    There is no "B" key -- and that's my problem. It tells me about other
    facet values if they're filtered out by fq, but it tells me nothing
    about facet values that aren't present in any doc.
   
    My question is how to force the response to be
    "facet_fields":{
          "enumfield":[
            "A",0,
            "B", 0]}
   
   
    2019-01-05, št, 19:42 Erick Erickson <[hidden email]> rašė:
   
    > So really the results you want are q=*:*&facet.field=enumField right?
    > You could fire that query in parallel and combine the two in your app,
    > perhaps caching the result if the index isn't changing very rapidly.
    >
    > Facets were designed with the idea that they'd only count for docs
    > that were hits, so there's no built-in way to do what you want. Which, BTW,
    > could be _very_ expensive in the general case. The query would
    > have to count up, say, the hits for 100M documents...
    >
    > Best,
    > Erick
    >
    > On Sat, Jan 5, 2019 at 1:53 AM Arvydas Silanskas
    > <[hidden email]> wrote:
    > >
    > > Hello,
    > > I have an enum solr fieldtype. When I do a facet search, I want that all
    > > the enum values appear in the facet -- and setting field.mincount = 0 is
    > > not enough. It only works, if there exist a document with the matching
    > > value for the field, but it was filtered out by current query (and then
    > I'm
    > > returned that facet value with the count 0). But can I make it to also
    > > return the values that literally none of the documents in the index have?
    > > The values, that only appear in the enum declaration xml.
    >
   
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to force solr show all facet values for the field with an enum type?

Arvydas Silanskas
In reply to this post by Mikhail Khludnev-2
Feared as much, but now at least I know for sure. Thank you.

2019-01-05, št, 22:19 Mikhail Khludnev <[hidden email]> rašė:

> Hello,
> On Sat, Jan 5, 2019 at 12:53 PM Arvydas Silanskas <
> [hidden email]> wrote:
>
> > But can I make it to also
> > return the values that literally none of the documents in the index have?
> >
> No.
>
> --
> Sincerely yours
> Mikhail Khludnev
>
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to force solr show all facet values for the field with an enum type?

Arvydas Silanskas
In reply to this post by David Santamauro
I haven't checked if it works, but even if it did, that would kinda defeat
the purpose -- namely not repeating enum values
in multiple places, and have them all contained in the single spot
(enumConfig.xml)

2019-01-06, sk, 11:43 David Santamauro <[hidden email]> rašė:

> Seeing that the field is an enumeration, couldn't you just use a set of
> facet.query(s)?
>
>   ?q=*:*
>   &fq=user_s:Bar
>   &facet=true
>   &facet.query=enumfield:A
>   &facet.query=enumfield:B
>   &facet.mincount=0
>
> //
>
> On 1/5/19, 3:01 PM, "Arvydas Silanskas" <[hidden email]>
> wrote:
>
>     Thanks for your reply.
>
>     No, not exactly what I want.
>
>     Consider I have enum defined as
>
>     <enum name="Enum">
>         <value>A</value>
>         <value>B</value>
>     </enum>
>
>     and correspondingly I have defined a fieldtype "enumType" that uses
> this
>     enum, and a field "enumfield" that is of type "enumType". Consider my
> index
>     is like this:
>
>     [
>           {
>             "name_s":"Doc 1",
>             "enumfield":"A",
>             "user_s":"Foo",
>             "id":"2ebc0754-e7d8-405e-9962-99c6cd1d9275",
>             "_version_":1621850725207244800},
>           {
>             "name_s":"Doc 2",
>             "user_s":"Bar",
>             "id":"0536827a-703a-456e-9087-71b85b63c58b",
>             "_version_":1621850725397037056}]
>
>     notice how there are no documents that have "enumfield":"B".
>     Now, if I execute query
>     "facet.field=enumfield&facet=on&fq=user_s:Bar&indent=on&q=*:*&wt=json",
>     my facet response's fields look like this:
>
>     "facet_fields":{
>           "enumfield":[
>             "A",0]}
>
>     There is no "B" key -- and that's my problem. It tells me about other
>     facet values if they're filtered out by fq, but it tells me nothing
>     about facet values that aren't present in any doc.
>
>     My question is how to force the response to be
>     "facet_fields":{
>           "enumfield":[
>             "A",0,
>             "B", 0]}
>
>
>     2019-01-05, št, 19:42 Erick Erickson <[hidden email]> rašė:
>
>     > So really the results you want are q=*:*&facet.field=enumField right?
>     > You could fire that query in parallel and combine the two in your
> app,
>     > perhaps caching the result if the index isn't changing very rapidly.
>     >
>     > Facets were designed with the idea that they'd only count for docs
>     > that were hits, so there's no built-in way to do what you want.
> Which, BTW,
>     > could be _very_ expensive in the general case. The query would
>     > have to count up, say, the hits for 100M documents...
>     >
>     > Best,
>     > Erick
>     >
>     > On Sat, Jan 5, 2019 at 1:53 AM Arvydas Silanskas
>     > <[hidden email]> wrote:
>     > >
>     > > Hello,
>     > > I have an enum solr fieldtype. When I do a facet search, I want
> that all
>     > > the enum values appear in the facet -- and setting field.mincount
> = 0 is
>     > > not enough. It only works, if there exist a document with the
> matching
>     > > value for the field, but it was filtered out by current query (and
> then
>     > I'm
>     > > returned that facet value with the count 0). But can I make it to
> also
>     > > return the values that literally none of the documents in the
> index have?
>     > > The values, that only appear in the enum declaration xml.
>     >
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to force solr show all facet values for the field with an enum type?

Erik Hatcher-4
In reply to this post by Arvydas Silanskas
How about &facet.query=-field:[* TO *] as a way to see a count of docs that don’t have field?

    Erik

> On Jan 5, 2019, at 04:45, Arvydas Silanskas <[hidden email]> wrote:
>
> Hello,
> I have an enum solr fieldtype. When I do a facet search, I want that all
> the enum values appear in the facet -- and setting field.mincount = 0 is
> not enough. It only works, if there exist a document with the matching
> value for the field, but it was filtered out by current query (and then I'm
> returned that facet value with the count 0). But can I make it to also
> return the values that literally none of the documents in the index have?
> The values, that only appear in the enum declaration xml.