Thank Eric. It worked but I am also restricting the fragment-scope to 
properties. Does this restrict the search results only to title (searched with 
title:Book). My documents contain the word Book in title as well as 
description. I want to restrict my search results to the ones in title only.is 
this possible?I am using following JSON{"options": {"constraint": [{"name": 
"title","word": {"json-property": "title","fragment-scope" : 
"properties"}}]}}regards,Puneet

From: [email protected]
To: [email protected]
Date: Mon, 4 May 2015 12:57:31 +0000
Subject: Re: [MarkLogic Dev General] custom search: Field contraint












Hi, Puneet:



To search with a single word instead of the full value, use a word constraint:



    http://docs.marklogic.com/guide/rest-dev/appendixa#id_72270





Erik Hennum










From: [email protected] 
[[email protected]] on behalf of Yinyan guy 
[[email protected]]

Sent: Monday, May 04, 2015 4:25 AM

To: MarkLogic Developer Discussion

Subject: Re: [MarkLogic Dev General] custom search: Field contraint






Hi Eric,
Thank you for your tip. I added the value constraint and it did allow me to 
search with title:"The Book Title".
However it requires me to add the complete title. What would allow me to search 
with just one word like title:book?
regards,
Puneet






From: [email protected]

To: [email protected]

Date: Sun, 3 May 2015 13:33:55 +0000

Subject: Re: [MarkLogic Dev General] custom search: Field contraint









Hi, Yinyan:




A collection is a named set to which documents can be added.  Thus, a 
collection constraint will search for the documents that are members of the 
specified collections.



To match the value of a JSON property, use a value constraint.  Please see:



    http://docs.marklogic.com/guide/rest-dev/appendixa#id_48883



In the example, that would look similar to the following (untested) options: 



    {"options": {"constraint": [{"name": "title", "value": {"json-property": 
"title"}}]}}



You can also use a range constraint if you need datatyped matching or 
comparison (for which you must defined a range index in advance using the Admin 
UI):



    http://docs.marklogic.com/guide/rest-dev/appendixa#id_93906



For more information about collections, please see:



    http://docs.marklogic.com/guide/search-dev/collections



You might also want to know that, in MarkLogic, the term "field" connotes an 
abstraction over JSON properties or XML elements:



    http://docs.marklogic.com/guide/admin/fields






Hoping that helps,






Erik Hennum










From: [email protected] 
[[email protected]] on behalf of Yinyan guy 
[[email protected]]

Sent: Sunday, May 03, 2015 3:44 AM

To: [email protected]

Subject: [MarkLogic Dev General] custom search: Field contraint






Hi All,
I am trying to implement Field search using REST Search API. The JSON structure 
of all my document is as follows



{

"id" : 1,
"title" : "The Book Title"
"price" : "$100"

}



and I would want to search title:Book using my search API 
("http://localhost:8040/v1/search?q=title:mini";)



I have tried using all the following options to update the settings




curl -v -X PUT  --digest --user admin:admin  -H "Content-type: 
application/json" -d '{"options": {"constraint": [{"collection": {"prefix": 
"\title"},"name": "title"}]}}' 'http://localhost:8040/v1/config/query/entitle2'




curl -v -X PUT  --digest --user admin:admin  -H "Content-type: 
application/json" -d '{"options": {"constraint": [{"collection": {"prefix": 
"title"},"name": "title"}]}}' 'http://localhost:8040/v1/config/query/entitle1'




curl -v -X PUT  --digest --user admin:admin  -H "Content-type: 
application/json" -d '{"options": {"constraint": [{"collection": {"prefix": 
"title/"},"name": "title"}]}}' 'http://localhost:8040/v1/config/query/entitle'



All the above commands worked fine and I can see all of these constraints in 
("http://localhost:8040/v1/config/query?format=json";) but none
 of them return any results.



I have following questions



1. what would be right path for my JSON? (title. title/,\title)
2. is this the right way to customize the search API?



Thanks in advance.
regards.
Puneet







_______________________________________________ General mailing list 
[email protected] Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general








_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general                         
                  
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to