[deepamehta-devel] Using the DM search through the REST API

Jörg Richter jri at deepamehta.de
Wed Mar 18 03:41:52 CET 2015


Hi Jürgen,

you can use DM's fulltext search:

	http://localhost:8080/core/topic?search=Kloppstockstr.&field=dm4.contacts.street

"search" is what you are looking for.
"field" is the type URI of the topics you want to search.
(The "field" parameter is optional. If not specified you'll search ALL topics, regardless of type.)
The result is an array of topics. The array might be empty.

A topic is an object with 5 properties: "id", "uri", "type_uri", "value", "childs".
"value" is the actual payload.
"childs" are the child topics of a composite topic. Note: these will be included in the response only when you specify an additional parameter:

	...&include_childs=true

Hint: when trying via curl you need to escape the & as \& 


## Search Syntax (the "search" parameter) ##

When using several words (separated by spaces) the words are ORed by default. That is

	Klopstockstr. 20

matches a Street topic when it contains "Klopstockstr." OR "20"
To match it as a phrase (this is what you likely want) put it in quotes:

	"Klopstockstr. 20"

IMPORTANT: in an URL you must encode characters like space and quote like this:

	%22Klopstockstr.%2020%22

You can also use wildcards and other things. Actually you can use the entire Lucene Query Syntax:
http://lucene.apache.org/core/3_5_0/queryparsersyntax.html


## DM Contacts hints ##

You can also search in composite topics like "dm4.contacts.person_name" or "dm4.contacts.address".

DM concatenates the value of those composite topics as follows:

	<First Name> <Last Name>
	<Street> <Postal Code> <City> <Country>

So when you search for "Klopstockstr. 20 10557 Berlin" you'll find that exact Address topic. (Don't forget to URL encode the spaces and quotes.)

IMPORTANT: you'll find topics as described here only if they are indexed with mode "Fulltext Key". This is the case e.g. for all the types mentioned here, also the composite ones like "Person Name" and "Address". However, this is NOT the case for the "Person" type. So, at the moment you can't search for "Person" topics by their name, but only for "Person Name" topics. But you can navigate from a Person Name topic to a Person topic by an additional request.

You see a type's index mode(s) in the detail panel when selecting a type topic.

Tell me if you need further info.

Cool your Python script is growing :-)

Cheers,
Jörg


On Mar 15, 2015, at 17:25, Juergen Neumann wrote:

> Dear Jörg,
> 
> my Python script for VCARD import is evolving quite well. Recently I do
> the search myself but now I would like use the DM search to reduce the
> web traffic and memory usage.
> 
> I need to search for the person string (firstname lastname) and all
> address elements (the full composite) and all of its parts.
> 
> Could you send me an example please on how to use the DM search for my
> purpose. Lets say I want to check if a person (Martina Mustermann)
> already exists. If yes, I want to check if her address equals the
> address in my VCARD. If not, I want to update the address, by checking
> if the whole address already exists. If not, I want to check if the
> elements (partly) already exist. If yes, I want to reuse what ever is
> there already.
> 
> How can I use the DM search for this purpose?
> 
> Thank you very much!
> 
> JuergeN 



More information about the devel mailing list