Skip to main content

Getting Started with Fulltext Search

This page guides you through creating and querying your first fulltext search view.


  • A Macrometa account with sufficient permissions to create search views.
  • The addresses collection created during the first two steps of the Quickstart.

1. Create a Search View

You are going to create a search view on the document collection that you created in the Quickstart. For an explanation of how search views function, refer to the Fulltext Search Tasks section.

  1. Log in to your Macrometa account.
  2. Click Data > Search Views.
  3. Click New View.
  4. In the Search View Name field, enter addresses_view.
  5. In View Type, select Fulltext Search.
  6. In the Collection list, select addresses.
  7. Enter lastName in Field and then select text_en in the ANALYZER list.
  8. Click Add Collection twice.
  9. Perform steps 6 and 7 again for the firstName and email fields in the addresses collection.
  10. Click Create.

Your three address collection key values are indexed in the search view and ready to query. Macrometa distributes this search view to every location in the global fabrics. If you're curious about the locations, click Dashboard to see the default Fabric locations.

New Search View

2. Query the Search View

To query the search view, you can create a query in Macrometa to run it as needed or save it as a query worker.

  1. On the side menu, click Compute > Query Workers.

  2. If the code editor is not empty, then click New Query.

  3. The code block below is a search query that will allow you to pass in a query parameter to search the search view. Copy and paste it in the code editor on line 1.

    FOR contact IN addresses_view
    BOOST(STARTS_WITH(contact.firstName, @searchTerm), 3) OR
    BOOST(STARTS_WITH(contact.lastName, @searchTerm), 2) OR
    BOOST(STARTS_WITH(, @searchTerm), 1),
    SORT BM25(contact) DESC
    RETURN UNSET(contact, ["_id", "_rev"])
  4. Enter the word nemo to the searchTerm value to the right of the editor window.

  5. Click Run Query. Macrometa displays query results below the row of buttons.

  6. (Optional) Click Query Info in the Query Result to see what the query did and how long each step took. Pretty cool if you're into performance metrics.

3. (Optional) Save the Query as an API Endpoint

When you save a query worker, you can access it via REST API from anywhere in the world in under 50ms.

  1. Click Save Query.
  2. Name the query getContactBySearchTerm and then click Save. This saves the query so you can use it again.
  3. Click Run Query.
  4. Click API Endpoint.

This query requires a value to be passed with each request, so you must enter one in the bind parameters or else the query will fail with an error.

Save as API Endpoint