新しいBoxサポートサイトへようこそ。 変更点の詳細はこちらをご確認ください .

コメント

3件のコメント

  • Rui Barbosa

    Hi Shirakawa san,

    According to our documentation that is how it is supposed to work:

    "" - by wrapping a query in double quotes only exact matches are returned by the API. Exact searches do not return search matches based on specific character sequences. Instead, they return matches based on phrases, that is, word sequences. For example: A search for "Blue-Box" may return search results including the sequence "blue.box""Blue Box", and "Blue-Box"; any item containing the words Blue and Box consecutively, in the order specified.

    But what does this mean?

    Consider the following:

    Similar to your use case.

    You didn't mention if you are using the REST API directly or an SDK (like python), so I'll use postman to interact directly with the API.

    The first concept is that search is done over an indexed database, which includes names, description, tags, and content. 

    This means it is searching for apple in many attributes, not just the name. However we can reduce that search scope and even filter out by object types (i.e. file, folder).

    Please note that it takes a few minutes for search to index a new entries, just in case your are testing with content that you just created, which can influence your tests.

    Assuming you want to search for apple, only on name with an "exact" match, returning only folders, and for simplicity, only include type, id and name in the output, your API call would look like:

    https://{{api.box.com}}/2.0/search
    ?query="apple" -> search for string apple using "exact" match
    &content_types=name -> search only in name
    &type=folder -> return only folder objects
    &fields=type,id,name -> only include type, id and name

    and from my example would return:

    {
        "total_count": 8,
        "entries": [
            {
                "type": "folder",
                "id": "199904744351",
                "etag": "0",
                "name": "apple pineapple banana"
            },
            {
                "type": "folder",
                "id": "199904090719",
                "etag": "0",
                "name": "banana apple"
            },
            {
                "type": "folder",
                "id": "199903162104",
                "etag": "0",
                "name": "apple banana"
            },
            {
                "type": "folder",
                "id": "199903934571",
                "etag": "0",
                "name": "apple pineapple"
            },
            {
                "type": "folder",
                "id": "199903660834",
                "etag": "0",
                "name": "apple12"
            },
            {
                "type": "folder",
                "id": "199900919201",
                "etag": "0",
                "name": "apple2"
            },
            {
                "type": "folder",
                "id": "199902185577",
                "etag": "0",
                "name": "apple3"
            },
            {
                "type": "folder",
                "id": "199902137207",
                "etag": "0",
                "name": "apple1"
            }
        ],
        "limit": 30,
        "offset": 0
    }

    In other words, it returns anything that has the word apple, including apple1, apple2 and apple3, but not pineapple.

    Now if I look for "apple banana" using:

    https://{{api.box.com}}/2.0/search?query="apple banana"&content_types=name&type=folder&fields=type,id,name

    I only get 1 entry:

    {
        "total_count": 1,
        "entries": [
            {
                "type": "folder",
                "id": "199903162104",
                "etag": "0",
                "name": "apple banana"
            }
        ],
        "limit": 30,
        "offset": 0
    }

    Notice it did not pickup "apple pineapple banana", neither "banana apple", nor apple1, apple2 and apple3.

    In summary "exact" match is not what we as developers are expecting. This works more like a word in sequence search.

    I'm not sure what your real life use case is, hope you can use the narrowing of the scope, and this helped some how.

    Lets us know.

    Best regards

     

    0
    コメントアクション Permalink
  • 白川博之

    Wow sorry for too late reply.

    Thank you for detailed instructure. Yes you are right, I tried with REST API and I wanted to execute "literally" exact match search.

    Oh, Ok I understood Box get-search API is not what I expect so far.

    Thank you. You have perfectly answered my question!

    0
    コメントアクション Permalink
  • Rui Barbosa

    You are most welcome Hiroyuki.

    Depending on your use case, I'm wondering if the metadata search could be applied...

    Metadata search is a much more sophisticated and precise search mechanism, but it can only be used if you have metadata.

    Here are a few of articles about metadata from a developer perspective (the translated Japanese version):

    Best regards

    0
    コメントアクション Permalink

サインインしてコメントを残してください。