Reputation: 49
I am new to MarkLogic. Is it possible to make a search application in such a way that when a user makes a search he/she receives the URI links of the documents along with a little bit of summary? When they click on the URI link they get to see the full document. I also want to give collection facets which will further filter the records. There are some fields that I want to use as facets, these fields are present in documents of some collections but are not present in other collections. However, these collections do have a common unique field which can be used for making joins or linking them. I want to know, how is it possible? How do we make collection facets? How do we make a join on different collections? How do we make the URI link clickable and direct the users to a full document? I want to answer questions like show me all the maintenance documents that have word 'housekeeping' in them, then I click on the names of the locations (location info could be in a different collection) to further narrow the search or I can click on the names of the employees who worked on these "housekeeping" jobs to further narrow the search. I would really appreciate your help. I built a search app just like Top-Songs from MarkLogic tutorials but it had just one collection and same XML schema for all the documents but now different collections and different XML schema are confusing to me. Please also tell me whether I should use Search API or cts:search to achieve this. Is this achievable by keeping these collections separate or do I need to denormalize them?
I would really appreciate your help. much regards
Upvotes: 0
Views: 149
Reputation: 20414
I'd recommend having a look at slush-marklogic-node. It is a generator that creates you a complete project with a fairly full-featured search app. It comes with some JSON sample-data, and has some example facets that work with it, but you can also upload other data, and play with that, provided you put it in the 'data' collection.
It runs on a slightly outdated stack unfortunately, but it is fairly stable, and might give you good ideas on how to approach certain aspects. Once deployed properly, it should look like this:
http://slush-default.demo.marklogic.com/
Update:
Regarding facets on collections, the generated app comes with several example facets of which the first is based on collections. It is driven by the faceting capabilities of the REST endpoint /v1/search
, which in turn builds on top of search:search()
. That function takes so-called search options that can define constraints. Here two examples:
<!-- Facet based on document collections, simple yet elegant -->
<constraint name="Collection">
<collection facet="true" />
<!-- optionally enable a prefix to see a specific subset of facets
<collection facet="true" prefix="data/" />
-->
</constraint>
<!-- Example range facet based on the sample-data -->
<constraint name="eyeColor">
<range type="xs:string" facet="true" collation="http://marklogic.com/collation/codepoint">
<facet-option>limit=5</facet-option>
<facet-option>frequency-order</facet-option>
<facet-option>descending</facet-option>
<path-index>eyeColor</path-index>
</range>
</constraint>
HTH!
Upvotes: 1