当前位置: 动力学知识库 > 问答 > 编程问答 >

mql - Searching for a property in Freebase

问题描述:

What would be the MQL query if I want to search for a property that has a particular string either in its name or the actual link path. For name, I was able to put a ~= matching on the name property, but not in the link path. I tried to use the ~= in the id, but it says we cannot do matching in the id.

[{

"/type/object/id": "wikipedia",

"name~=": "wikipedia",

"/type/object/type": "/type/property",

"/type/object/name": null

"limit": 200

}]​

Is there a way to also search for strings in the id ?

网友答案:

A couple of things:

  • the ~= operator works on a whole word basis, so if you want to find the string "wikipedia" in all contexts, you'll want to use "*wikipedia*"
  • IDs aren't stored with fully formed paths, instead they're a sequence of keys in their respective namespaces (think filenames in directories)

You'll need two separate queries to match both the properties and their containing domains since you can't do unions like that in MQL.

For properties who's names contain wikipedia:

[{
  "type": "/type/property",
  "name~=" : "*wikipedia*",
  "name": null,
  "id":null,
  "limit":         200
}]​

and for properties which belong to types who's IDs contain wikipedia:

[{
  "type": "/type/property",
  "name": null,
  "id":null,
  "schema" : {"key":{"namespace":{"name~=":"*wikipedia*"}},"id":null},
  "limit":         200
}]​

That second query may need a little refinement, but it should give you the basic idea.

分享给朋友:
您可能感兴趣的文章:
随机阅读: