marklogic-community / slush-marklogic-node

Slush generator for a MarkLogic/node project
https://github.com/marklogic-community/slush-marklogic-node/wiki
Other
40 stars 28 forks source link

Facet counts too high #492

Closed twvantongeren closed 7 years ago

twvantongeren commented 7 years ago

I am using the "cards" template. I have limited the number of facets per category in the "all.xml" file to 5, which introduces a "see more" button then the number of facets per category should be limited. If I now use the the "see more" button, facets seem to have the wrong count. For example The facet for eyecolor would show "brown(10)" when I now click on (+) the number of cards reduces to 5 cards.

grtjn commented 7 years ago

I recall ml-search not always taking search string into account, but would have to check if that is the case here too.

Were you using an unchanged cards theme slush app with the out of the box sample data?

grtjn commented 7 years ago

I have trouble reproducing the issue locally with latest version (1.3.0). Can you elaborate on the specifics of how you setup and configured your cards theme app? I tested with a vanilla cards theme application, with sample data loaded, and I only added show-more="$ctrl.showMoreFacets(facet, facetName)" to the ml-facets directive ui/app/search/search.html. The eyeColor facet is already limited to 5 by default. If i click show more from initial search, extra values and counts look right. Same when I repeat with male facet value selected. And also same when I do an FT search on male.

twvantongeren commented 7 years ago

Thanks for your quick response, no I have not found the issue in the unchanged cards theme, we are using quite different data and also different path-indexes to create the facets. There are quite some differences compared to the original application. If I run slush on my terminal I get marklogic-node (1.3.0) in the list of generators. I will tomorrow make a new project, and then try to reproduce the issue with a version which is close to the original cards theme, so I can report to you how get the reported issue.

twvantongeren commented 7 years ago

Dear grtjn, I hope this can help you.

Download all packages needed to run slush: I am using versions:

marklogic-node 1.3.0
MarkLogic 8.0-5.5
mlcp-8.0-5
slush 1.1.1
Browser Firefox: 51.0.1 (64-bit)

run:

slush marklogic-node facet-test

questions to answer for the script:

version: 8
MarkLogic Host: localhost
MarkLogic Admin User: admin
MarkLogic Admin Password: admin
MarkLogic App/Rest port: 8040
Node app port: 9070
Select Template: Cards
Allow anonymous users: false
Disallow proxying: false
Only allow access to users created for app: false

Execute:

cd facet-test/
./ml local bootstrap
./ml local deploy modules && ./ml local deploy content

I have to add the location of mlcp in local.properties, this might be different for you:

cd deploy/
local.properties[l30] add: mlcp-home=~/.mlBin/mlcp-8.0-5
cd ..

place all data in a different collection than the standard "data" collection: rest-api/config/options/all.xml[l8] change <cts:uri>data</cts:uri> into: <cts:uri>my-custom-collection</cts:uri>

Place the new changes into the database:

./ml local bootstrap && ./ml local deploy modules

In: import-sample-data.options [l9] change :

-output_collections
data,data/people

to:

-output_collections
my-custom-collection

run data import:

./ml local mlcp -options_file import-sample-data.options

run frontent installation:

npm install
bower install
gulp init-local

run the following script against facet-test-content, for example in Query-console:

xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml";
let $json := '{
  "_id": "55ee5e44f77dd7dab6656cdf",
  "index": 1,
  "guid": "c7511a55-afb3-4476-8dd9-43c3d96fb55f",
  "isActive": false,
  "balance": "$22,002.95",
  "picture": "http://placehold.it/32x32",
  "age": 69,
  "eyeColor": "white",
  "name": "Mathews Mccray",
  "gender": "male",
  "company": "STREZZO",
  "email": "mathewsmccray@strezzo.com",
  "phone": "+1 (991) 531-2420",
  "address": "731 Brightwater Court, Fontanelle, Missouri, 6921",
  "registered": "2015-05-14T02:28:53-07:00"
}'
return
   xdmp:document-insert("/next.json", xdmp:unquote($json));
   xdmp:document-add-collections("/next.json", "some-other-collection")

make the suggested change in ui/app/search/search.html add show-more="$ctrl.showMoreFacets(facet, facetName)" to ml-facets element on r9 which becomes:

<ml-facets show-more="$ctrl.showMoreFacets(facet, facetName)" facets="$ctrl.response.facets" toggle="$ctrl.toggleFacet(facet, value)" active-facets="$ctrl.mlSearch.activeFacets" negate="$ctrl.toggleNegatedFacet(facet,value)"></ml-facets>

run gulp-server:

gulp serve-local

login: I do this with admin:admin

newfacet facet-nr

grtjn commented 7 years ago

@twvantongeren, thanks for the elaborate test case. I ran through as accurately as possible, but I don't get the facet value for white..

You say you tested with admin/admin. Could it be that you have deleted fragments that throw off facet values and counts? If you still have that white (1) showing up at your end, try the following steps:

Let me know the results..

grtjn commented 7 years ago

Tried again just now, still cannot reproduce. Closing ticket for now until new evidence appears..