Hi Danny, In addition to the approaches Dave outlined, you could define a field on <name/>. Given your example, you would give get a field value of "Smith John R.". To get your preferred value, you'd need to transform your input, and reverse the order of your surname and given-name elements.
Thanks. -jb From: Dave Cassel <[email protected]<mailto:[email protected]>> Reply-To: MarkLogic Developer Discussion <[email protected]<mailto:[email protected]>> Date: Monday, April 20, 2015 at 3:19 PM To: MarkLogic Developer Discussion <[email protected]<mailto:[email protected]>> Subject: Re: [MarkLogic Dev General] Lexicon for author names Hi Danny, There's no way to build an index on your XML below that will result in "John R. Smith" as a value. The common approach is to adjust your data to something like: <contrib contrib-type="author"> <name full="John R. Smith"> <surname>Smith</surname> <given-names>John R.</given-names> </name> <degrees>Ph.D.</degrees> </contrib> Alternatives… you could muck around with things at run time. If you wanted to search for "John R. Smith" as an author, you could do a custom constraint that breaks up the string into given-name and surname parts, then does an and-query (or near-query, if you could have more than one author in a document). If you want to build a facet on those values, you could try either a custom facet the uses co-occurrences (specify proximity=1 to make sure you don't get combinations of all authors), or you might be able to build a UDF to do the same thing. In either case, you'd have to watch for multiple authors messing you up, and I'd expect either approach would be slower than combining the values ahead of time and being able to set up a single index (like name/@full above). Dave. -- Dave Cassel<http://davidcassel.net>, @dmcassel<https://twitter.com/dmcassel> Developer Community Manager MarkLogic Corporation<http://www.marklogic.com/> Data Innovation Summit<http://fedscoop.com/events/datainnovationsummit/2015/> May 7th in DC From: Danny Sinang <[email protected]<mailto:[email protected]>> Reply-To: MarkLogic Developer Discussion <[email protected]<mailto:[email protected]>> Date: Monday, April 20, 2015 at 2:50 PM To: general <[email protected]<mailto:[email protected]>> Subject: [MarkLogic Dev General] Lexicon for author names I'd like to create a lexicon for author names but our XML structure for those names goes like this : <contrib contrib-type="author"> <name> <surname>Smith</surname> <given-names>John R.</given-names> </name> <degrees>Ph.D.</degrees> </contrib> Is it possible to create a single path range index ? If so, how do I formulate the XPath for the index ? And once the index is created, how do I express the author name in the $value parameter to a call to cts:path-range-query () ? Regards, Danny
_______________________________________________ General mailing list [email protected] Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
