Solr — forcing facet to show enum fields that aren't currently present in any document












0















I have a field which can have known set of string values, and it is of EnumField type.



Is there a way to force Solr to return all facet values for it? The facet.mincount=0 property only works if there are existing documents with corresponding facet field value, however they were filtered out in current search using e.g. fq.



However, if none current documents have that value, it doesn't show up at all.





Consider I have a field type, which is defined as an enum, and can have values A and B. And let's say I have imported such docs:



[{
"name_s": "Doc 1",
"type": "A",
"user_s": "Foo"
}, {
"name_s": "Doc 2",
"user_s": "Bar"
}]


If I do a facet query on the field type using a filter query by user "Bar", the only facet value I am returned is "A" with the count of 0. My goal is to force it to return both values "A" and "B" in such scenario (and both having count 0).










share|improve this question

























  • do you want to see facet values even for documents that aren't matched by the query?

    – Mysterion
    Jan 2 at 12:20











  • Yes, in particular when those facet values are defined as enum

    – Coderino Javarino
    Jan 2 at 12:28











  • could you elaborate on this?enum as predefined values? how would Solr know about your enum somewhere?

    – Mysterion
    Jan 2 at 12:30











  • I'm specifically talking about solr's enum, as seen e.g. here lucene.apache.org/solr/guide/6_6/working-with-enum-fields.html

    – Coderino Javarino
    Jan 2 at 12:31











  • yeah, but in this sense, EnumField is no different in terms of faceting as other field types, facets are calculated on matched docset only. I could think of some idea if you have fq that could be ignored and you want to return results ignoring it. Will it be ok?

    – Mysterion
    Jan 2 at 12:37


















0















I have a field which can have known set of string values, and it is of EnumField type.



Is there a way to force Solr to return all facet values for it? The facet.mincount=0 property only works if there are existing documents with corresponding facet field value, however they were filtered out in current search using e.g. fq.



However, if none current documents have that value, it doesn't show up at all.





Consider I have a field type, which is defined as an enum, and can have values A and B. And let's say I have imported such docs:



[{
"name_s": "Doc 1",
"type": "A",
"user_s": "Foo"
}, {
"name_s": "Doc 2",
"user_s": "Bar"
}]


If I do a facet query on the field type using a filter query by user "Bar", the only facet value I am returned is "A" with the count of 0. My goal is to force it to return both values "A" and "B" in such scenario (and both having count 0).










share|improve this question

























  • do you want to see facet values even for documents that aren't matched by the query?

    – Mysterion
    Jan 2 at 12:20











  • Yes, in particular when those facet values are defined as enum

    – Coderino Javarino
    Jan 2 at 12:28











  • could you elaborate on this?enum as predefined values? how would Solr know about your enum somewhere?

    – Mysterion
    Jan 2 at 12:30











  • I'm specifically talking about solr's enum, as seen e.g. here lucene.apache.org/solr/guide/6_6/working-with-enum-fields.html

    – Coderino Javarino
    Jan 2 at 12:31











  • yeah, but in this sense, EnumField is no different in terms of faceting as other field types, facets are calculated on matched docset only. I could think of some idea if you have fq that could be ignored and you want to return results ignoring it. Will it be ok?

    – Mysterion
    Jan 2 at 12:37
















0












0








0








I have a field which can have known set of string values, and it is of EnumField type.



Is there a way to force Solr to return all facet values for it? The facet.mincount=0 property only works if there are existing documents with corresponding facet field value, however they were filtered out in current search using e.g. fq.



However, if none current documents have that value, it doesn't show up at all.





Consider I have a field type, which is defined as an enum, and can have values A and B. And let's say I have imported such docs:



[{
"name_s": "Doc 1",
"type": "A",
"user_s": "Foo"
}, {
"name_s": "Doc 2",
"user_s": "Bar"
}]


If I do a facet query on the field type using a filter query by user "Bar", the only facet value I am returned is "A" with the count of 0. My goal is to force it to return both values "A" and "B" in such scenario (and both having count 0).










share|improve this question
















I have a field which can have known set of string values, and it is of EnumField type.



Is there a way to force Solr to return all facet values for it? The facet.mincount=0 property only works if there are existing documents with corresponding facet field value, however they were filtered out in current search using e.g. fq.



However, if none current documents have that value, it doesn't show up at all.





Consider I have a field type, which is defined as an enum, and can have values A and B. And let's say I have imported such docs:



[{
"name_s": "Doc 1",
"type": "A",
"user_s": "Foo"
}, {
"name_s": "Doc 2",
"user_s": "Bar"
}]


If I do a facet query on the field type using a filter query by user "Bar", the only facet value I am returned is "A" with the count of 0. My goal is to force it to return both values "A" and "B" in such scenario (and both having count 0).







solr






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 12:53







Coderino Javarino

















asked Jan 2 at 12:12









Coderino JavarinoCoderino Javarino

1,4191926




1,4191926













  • do you want to see facet values even for documents that aren't matched by the query?

    – Mysterion
    Jan 2 at 12:20











  • Yes, in particular when those facet values are defined as enum

    – Coderino Javarino
    Jan 2 at 12:28











  • could you elaborate on this?enum as predefined values? how would Solr know about your enum somewhere?

    – Mysterion
    Jan 2 at 12:30











  • I'm specifically talking about solr's enum, as seen e.g. here lucene.apache.org/solr/guide/6_6/working-with-enum-fields.html

    – Coderino Javarino
    Jan 2 at 12:31











  • yeah, but in this sense, EnumField is no different in terms of faceting as other field types, facets are calculated on matched docset only. I could think of some idea if you have fq that could be ignored and you want to return results ignoring it. Will it be ok?

    – Mysterion
    Jan 2 at 12:37





















  • do you want to see facet values even for documents that aren't matched by the query?

    – Mysterion
    Jan 2 at 12:20











  • Yes, in particular when those facet values are defined as enum

    – Coderino Javarino
    Jan 2 at 12:28











  • could you elaborate on this?enum as predefined values? how would Solr know about your enum somewhere?

    – Mysterion
    Jan 2 at 12:30











  • I'm specifically talking about solr's enum, as seen e.g. here lucene.apache.org/solr/guide/6_6/working-with-enum-fields.html

    – Coderino Javarino
    Jan 2 at 12:31











  • yeah, but in this sense, EnumField is no different in terms of faceting as other field types, facets are calculated on matched docset only. I could think of some idea if you have fq that could be ignored and you want to return results ignoring it. Will it be ok?

    – Mysterion
    Jan 2 at 12:37



















do you want to see facet values even for documents that aren't matched by the query?

– Mysterion
Jan 2 at 12:20





do you want to see facet values even for documents that aren't matched by the query?

– Mysterion
Jan 2 at 12:20













Yes, in particular when those facet values are defined as enum

– Coderino Javarino
Jan 2 at 12:28





Yes, in particular when those facet values are defined as enum

– Coderino Javarino
Jan 2 at 12:28













could you elaborate on this?enum as predefined values? how would Solr know about your enum somewhere?

– Mysterion
Jan 2 at 12:30





could you elaborate on this?enum as predefined values? how would Solr know about your enum somewhere?

– Mysterion
Jan 2 at 12:30













I'm specifically talking about solr's enum, as seen e.g. here lucene.apache.org/solr/guide/6_6/working-with-enum-fields.html

– Coderino Javarino
Jan 2 at 12:31





I'm specifically talking about solr's enum, as seen e.g. here lucene.apache.org/solr/guide/6_6/working-with-enum-fields.html

– Coderino Javarino
Jan 2 at 12:31













yeah, but in this sense, EnumField is no different in terms of faceting as other field types, facets are calculated on matched docset only. I could think of some idea if you have fq that could be ignored and you want to return results ignoring it. Will it be ok?

– Mysterion
Jan 2 at 12:37







yeah, but in this sense, EnumField is no different in terms of faceting as other field types, facets are calculated on matched docset only. I could think of some idea if you have fq that could be ignored and you want to return results ignoring it. Will it be ok?

– Mysterion
Jan 2 at 12:37














3 Answers
3






active

oldest

votes


















1














According to the mailing list, this is not possible at the moment.






share|improve this answer































    0














    If you're simple curious about to find all the terms present in field type you can easily find it using the term component of the Solr.



    Doc : https://lucene.apache.org/solr/guide/6_6/the-terms-component.html



    Doc is for version 6.6 you can change it accordingly the version you are currently working on.



    Here is sample url: http://localhost:8983/solr/collection/terms?terms.fl=type






    share|improve this answer
























    • But that is not what the question is about - the question wants to include all the possible values for the EnumField, even if there is no documents that contain that value. The terms component will not return those values unless they're present in a document, which is the same case that the OP originally asked (and used faceting to achieve).

      – MatsLindh
      Jan 6 at 14:37



















    -1














    You can achieve that by using tagging and excluding filters:



    You first tag your filter query: fq={!tag=my_tag}user_s:Bar



    And then you use the exclude tag in your facet: facet.field={!ex=my_tag}type






    share|improve this answer
























    • This would only affect the count of facet values, but it wouldn't include missing keys. Again, there isn't a single document with the value of "B" for the type field; in other words, a query type:B would return an empty set. The answer must resolve around the enum somehow, else how would solr know all the possible values?

      – Coderino Javarino
      Jan 2 at 14:57













    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54006152%2fsolr-forcing-facet-to-show-enum-fields-that-arent-currently-present-in-any-d%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    According to the mailing list, this is not possible at the moment.






    share|improve this answer




























      1














      According to the mailing list, this is not possible at the moment.






      share|improve this answer


























        1












        1








        1







        According to the mailing list, this is not possible at the moment.






        share|improve this answer













        According to the mailing list, this is not possible at the moment.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 5 at 22:30









        Coderino JavarinoCoderino Javarino

        1,4191926




        1,4191926

























            0














            If you're simple curious about to find all the terms present in field type you can easily find it using the term component of the Solr.



            Doc : https://lucene.apache.org/solr/guide/6_6/the-terms-component.html



            Doc is for version 6.6 you can change it accordingly the version you are currently working on.



            Here is sample url: http://localhost:8983/solr/collection/terms?terms.fl=type






            share|improve this answer
























            • But that is not what the question is about - the question wants to include all the possible values for the EnumField, even if there is no documents that contain that value. The terms component will not return those values unless they're present in a document, which is the same case that the OP originally asked (and used faceting to achieve).

              – MatsLindh
              Jan 6 at 14:37
















            0














            If you're simple curious about to find all the terms present in field type you can easily find it using the term component of the Solr.



            Doc : https://lucene.apache.org/solr/guide/6_6/the-terms-component.html



            Doc is for version 6.6 you can change it accordingly the version you are currently working on.



            Here is sample url: http://localhost:8983/solr/collection/terms?terms.fl=type






            share|improve this answer
























            • But that is not what the question is about - the question wants to include all the possible values for the EnumField, even if there is no documents that contain that value. The terms component will not return those values unless they're present in a document, which is the same case that the OP originally asked (and used faceting to achieve).

              – MatsLindh
              Jan 6 at 14:37














            0












            0








            0







            If you're simple curious about to find all the terms present in field type you can easily find it using the term component of the Solr.



            Doc : https://lucene.apache.org/solr/guide/6_6/the-terms-component.html



            Doc is for version 6.6 you can change it accordingly the version you are currently working on.



            Here is sample url: http://localhost:8983/solr/collection/terms?terms.fl=type






            share|improve this answer













            If you're simple curious about to find all the terms present in field type you can easily find it using the term component of the Solr.



            Doc : https://lucene.apache.org/solr/guide/6_6/the-terms-component.html



            Doc is for version 6.6 you can change it accordingly the version you are currently working on.



            Here is sample url: http://localhost:8983/solr/collection/terms?terms.fl=type







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 6 at 2:28









            Aman TandonAman Tandon

            590222




            590222













            • But that is not what the question is about - the question wants to include all the possible values for the EnumField, even if there is no documents that contain that value. The terms component will not return those values unless they're present in a document, which is the same case that the OP originally asked (and used faceting to achieve).

              – MatsLindh
              Jan 6 at 14:37



















            • But that is not what the question is about - the question wants to include all the possible values for the EnumField, even if there is no documents that contain that value. The terms component will not return those values unless they're present in a document, which is the same case that the OP originally asked (and used faceting to achieve).

              – MatsLindh
              Jan 6 at 14:37

















            But that is not what the question is about - the question wants to include all the possible values for the EnumField, even if there is no documents that contain that value. The terms component will not return those values unless they're present in a document, which is the same case that the OP originally asked (and used faceting to achieve).

            – MatsLindh
            Jan 6 at 14:37





            But that is not what the question is about - the question wants to include all the possible values for the EnumField, even if there is no documents that contain that value. The terms component will not return those values unless they're present in a document, which is the same case that the OP originally asked (and used faceting to achieve).

            – MatsLindh
            Jan 6 at 14:37











            -1














            You can achieve that by using tagging and excluding filters:



            You first tag your filter query: fq={!tag=my_tag}user_s:Bar



            And then you use the exclude tag in your facet: facet.field={!ex=my_tag}type






            share|improve this answer
























            • This would only affect the count of facet values, but it wouldn't include missing keys. Again, there isn't a single document with the value of "B" for the type field; in other words, a query type:B would return an empty set. The answer must resolve around the enum somehow, else how would solr know all the possible values?

              – Coderino Javarino
              Jan 2 at 14:57


















            -1














            You can achieve that by using tagging and excluding filters:



            You first tag your filter query: fq={!tag=my_tag}user_s:Bar



            And then you use the exclude tag in your facet: facet.field={!ex=my_tag}type






            share|improve this answer
























            • This would only affect the count of facet values, but it wouldn't include missing keys. Again, there isn't a single document with the value of "B" for the type field; in other words, a query type:B would return an empty set. The answer must resolve around the enum somehow, else how would solr know all the possible values?

              – Coderino Javarino
              Jan 2 at 14:57
















            -1












            -1








            -1







            You can achieve that by using tagging and excluding filters:



            You first tag your filter query: fq={!tag=my_tag}user_s:Bar



            And then you use the exclude tag in your facet: facet.field={!ex=my_tag}type






            share|improve this answer













            You can achieve that by using tagging and excluding filters:



            You first tag your filter query: fq={!tag=my_tag}user_s:Bar



            And then you use the exclude tag in your facet: facet.field={!ex=my_tag}type







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 2 at 13:14









            Tomer ArazyTomer Arazy

            1,673712




            1,673712













            • This would only affect the count of facet values, but it wouldn't include missing keys. Again, there isn't a single document with the value of "B" for the type field; in other words, a query type:B would return an empty set. The answer must resolve around the enum somehow, else how would solr know all the possible values?

              – Coderino Javarino
              Jan 2 at 14:57





















            • This would only affect the count of facet values, but it wouldn't include missing keys. Again, there isn't a single document with the value of "B" for the type field; in other words, a query type:B would return an empty set. The answer must resolve around the enum somehow, else how would solr know all the possible values?

              – Coderino Javarino
              Jan 2 at 14:57



















            This would only affect the count of facet values, but it wouldn't include missing keys. Again, there isn't a single document with the value of "B" for the type field; in other words, a query type:B would return an empty set. The answer must resolve around the enum somehow, else how would solr know all the possible values?

            – Coderino Javarino
            Jan 2 at 14:57







            This would only affect the count of facet values, but it wouldn't include missing keys. Again, there isn't a single document with the value of "B" for the type field; in other words, a query type:B would return an empty set. The answer must resolve around the enum somehow, else how would solr know all the possible values?

            – Coderino Javarino
            Jan 2 at 14:57




















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54006152%2fsolr-forcing-facet-to-show-enum-fields-that-arent-currently-present-in-any-d%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Mossoró

            Can't read property showImagePicker of undefined in react native iOS

            Pushsharp Apns notification error: 'InvalidToken'