marklogic / entity-services

Data modeling and code scaffolding for data integration in MarkLogic
https://docs.marklogic.com/guide/entity-services
Apache License 2.0
7 stars 10 forks source link

search-options() is not generated for element-range-index #343

Closed bsrikan closed 7 years ago

bsrikan commented 7 years ago

Used model valid-ref.json in e2e to generate search options. On deploy got below validate error:

XDMP-VALIDATEMISSINGATTR: (err:XQDY0027) validate strict { es:search-options-generate(fn:doc("valid-ref.json")) } -- Missing required attribute: Found () but required (@name & @ns?) at /*:options/*:constraint[6]/*:range/*:element using schema "search.xsd"

The search:constraint block looks like this:

<search:constraint name="ProductName">
<search:range type="xs:string" facet="true" collation="http://marklogic.com/collation/en">
<search:element xmlns:es="http://marklogic.com/entity-services">
</search:element>
</search:range>
</search:constraint>
grechaw commented 7 years ago

What's odd about this bug is that I have a test case, which looks like this one, that works. Something fishy going on...

grechaw commented 7 years ago

Ah, no, i do have a gap in my unit tests. I tested element range index with a namespace, but not without.

grechaw commented 7 years ago

OK, test and fix implemented. will push to new PR and then supplement with more fixes.

bsrikan commented 7 years ago

Get following error on e2e mldeploy. Attaching models for e2e: e2e_ns_Models.zip

Exception in thread "ThreadPoolTaskExecutor-2" com.marklogic.client.FailedRequestException: Local message: /config/query write failed: Bad Request. Server Message: RESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content: Operation results in invalid Options: XDMP-VALIDATEUNEXPECTED: (err:XQDY0027) validate strict { $opt } -- Invalid node: Found text{"
..."} but expected () at fn:doc("")/search:options/search:constraint[1]/search:value/search:element/text() using schema "search.xsd"text{"
..."}()fn:doc("")/search:options/search:constraint[1]/search:value/search:element/text()"search.xsd"
        at com.marklogic.client.impl.JerseyServices.putPostValueImpl(JerseyServices.java:3014)
        at com.marklogic.client.impl.JerseyServices.putValue(JerseyServices.java:2865)
        at com.marklogic.client.impl.QueryOptionsManagerImpl.writeOptions(QueryOptionsManagerImpl.java:158)
        at com.marklogic.client.modulesloader.impl.DefaultModulesLoader$3.run(DefaultModulesLoader.java:522)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Exception in thread "ThreadPoolTaskExecutor-1" com.marklogic.client.FailedRequestException: Local message: /config/query write failed: Bad Request. Server Message: RESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content: Operation results in invalid Options: XDMP-VALIDATEUNEXPECTED: (err:XQDY0027) validate strict { $opt } -- Invalid node: Found text{"
..."} but expected () at fn:doc("")/search:options/search:constraint[1]/search:value/search:element/text() using schema "search.xsd"text{"
..."}()fn:doc("")/search:options/search:constraint[1]/search:value/search:element/text()"search.xsd"
        at com.marklogic.client.impl.JerseyServices.putPostValueImpl(JerseyServices.java:3014)
        at com.marklogic.client.impl.JerseyServices.putValue(JerseyServices.java:2865)
        at com.marklogic.client.impl.QueryOptionsManagerImpl.writeOptions(QueryOptionsManagerImpl.java:158)
        at com.marklogic.client.modulesloader.impl.DefaultModulesLoader$3.run(DefaultModulesLoader.java:522)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
bsrikan commented 7 years ago

Please note that the model zip attached here is the one with namespaces. What we have now checked in e2e is the original model from 9.0-1 so mldeploy of e2e works. I wanted to have separate e2e tests for namespace. So if you generate artifacts with attached model and deploy you will see the error in the comment above.

grechaw commented 7 years ago

how do you go about generating them?

grechaw commented 7 years ago

do you sore the models anywhere in the source tree?
I'm finding that mlGenerateCode works great.

grechaw commented 7 years ago

Ah, i think you use the gradle task i made, duh

bsrikan commented 7 years ago

So I was able to deploy the new sub project I made with models having namespaces in them. Didnt get the error I reported in comment earlier. Must be a carriage return somewhere as you suspected @grechaw. Shipping this issue.