{
    "componentChunkName": "component---src-templates-article-page-template-js",
    "path": "/how-to/manage-search-schemas-with-flex-cli/",
    "result": {"data":{"markdownRemark":{"frontmatter":{"title":"Manage search schemas with Flex CLI","slug":"manage-search-schemas-with-flex-cli","updated":"2021-11-30T00:00:00.000Z","category":"how-to-search","ingress":"This tutorial shows you how to manage extended data search schemas with Flex CLI. With search schemas in place, you can use custom extended data fields as filters in your queries.","skills":"basic command line, text editing"},"htmlAst":{"type":"root","children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Flex CLI (Command-line interface) is a tool for changing your\nmarketplace's advanced configurations such as transaction processes and\nemail templates."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This tutorial expects that you have already installed Flex CLI and are\nlogged in with your API key. If not, it's recommended to first read the\ntutorial\n"},{"type":"element","tagName":"a","properties":{"href":"/docs/legacy/introduction/getting-started-with-flex-cli/"},"children":[{"type":"text","value":"Getting started with Flex CLI"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this tutorial, we will add data schemas for the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"category"}]},{"type":"text","value":" and\n"},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"amenities"}]},{"type":"text","value":" public data fields in listings. New marketplaces don't have\nany schemas in the backend by default since the needs of marketplaces\nvary. However, FTW (Flex Template for Web) does define filters for\ncategory and amenities in its UI (user interface). This tutorial will\nmake those filters work as expected."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We will also see how to manage data schema for user profiles. Those\nschemas are not required for FTW to work, but can be useful when\nbuilding own integrations via the Flex Integration API."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"extended-data-types-and-schema-scopes","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#extended-data-types-and-schema-scopes","ariaLabel":"extended data types and schema scopes permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Extended data types and schema scopes"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"There are "},{"type":"element","tagName":"a","properties":{"href":"/docs/legacy/references/extended-data/"},"children":[{"type":"text","value":"various types of extended data"}]},{"type":"text","value":".\nSearch schema is scoped to a particular type of extended data and the\nsupport differs depending on whether the schema is defined for listings\nor user profiles. The following table summarizes the supported search\nschema scopes."}]},{"type":"text","value":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"},{"type":"element","tagName":"table","properties":{},"children":[{"type":"element","tagName":"thead","properties":{},"children":[{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Schema for"}]},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Supported scopes"}]}]}]},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"listing"}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"public, metadata"}]}]},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"userProfile"}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"public, private, protected, metadata"}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"There is no API endpoint for querying users in the Marketplace API, so\n"},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"userProfile"}]},{"type":"text","value":" search schema applies only to the\n"},{"type":"element","tagName":"a","properties":{"href":"https://www.sharetribe.com/api-reference/integration.html#query-users","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"/users/query endpoint in the Integration API"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"All types of extended data are editable in Console by the operator, but\nonly public data and metadata can be seen by other marketplace users. To\nsee more details about extended data, see the\n"},{"type":"element","tagName":"a","properties":{"href":"/docs/legacy/references/extended-data/"},"children":[{"type":"text","value":"Extended data"}]},{"type":"text","value":" reference."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can store any JSON data in extended data, but only top-level keys of\ncertain type can have search schemas. If there is a mismatch between the\ndefined schema and what is stored to the extended data, the indexing\njust skips those values."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"schema-types-and-cardinalities","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#schema-types-and-cardinalities","ariaLabel":"schema types and cardinalities permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Schema types and cardinalities"}]},{"type":"text","value":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"},{"type":"element","tagName":"table","properties":{},"children":[{"type":"element","tagName":"thead","properties":{},"children":[{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Type"}]},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Cardinality"}]},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Example data"}]},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Example query"}]}]}]},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"enum"}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"one"}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"category: \"electric\""}]}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"pub_category=electric,wood"}]}]}]},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"multi-enum"}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"many"}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"amenities: [\"towels\", \"bathroom\"]"}]}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"pub_amenities=has_all:towels,bathroom"}]},{"type":"text","value":" or "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"pub_amenities=has_any:towels,bathroom"}]}]}]},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"boolean"}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"one"}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"hasLakeNearby: true"}]}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"pub_hasLakeNearby=true"}]}]}]},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"long"}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"one"}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"distanceToLake: 30"}]}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"pub_distanceToLake=5,40"}]}]}]},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"text"}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"one"}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"stoveDescription: \"Modern and powerful electric stove.\""}]}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"keywords=powerful%20modern"}]}]}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Data schema of type "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"text"}]},{"type":"text","value":" is currently only supported for listings."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Note that the scope in the examples above is "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"public"}]},{"type":"text","value":". Please use the\ncorrect prefix depending on the scope of the data ("},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"meta_"}]},{"type":"text","value":" for metadata,\n"},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"priv_"}]},{"type":"text","value":" for private data, "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"prot_"}]},{"type":"text","value":" for protected data and "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"pub_"}]},{"type":"text","value":" for\npublic data). Also, it's worth noting that the query parameter with a\n"},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"text"}]},{"type":"text","value":" schema is "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"keywords"}]},{"type":"text","value":" which also targets the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"title"}]},{"type":"text","value":" and\n"},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"description"}]},{"type":"text","value":" attributes of a listing. This query parameter is only\nsupported in listing queries. See\n"},{"type":"element","tagName":"a","properties":{"href":"/docs/legacy/concepts/how-the-listing-search-works/#keyword-search"},"children":[{"type":"text","value":"Keyword search"}]},{"type":"text","value":"\nfor more information."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{"id":"providing-multiple-query-params-for-a-single-field","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#providing-multiple-query-params-for-a-single-field","ariaLabel":"providing multiple query params for a single field permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Providing multiple query params for a single field"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can provide multiple values in the query parameter by separating\nthose with a comma. The matching behavior is different for different\nschema types."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"With the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"enum"}]},{"type":"text","value":" type like the category above, when you query\n"},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"pub_category=electric,wood"}]},{"type":"text","value":", you will match listings with either\n\"electric\" OR \"wood\" as the category. With the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"multi-enum"}]},{"type":"text","value":", you can\ncontrol the matching mode explicitly. The query\n"},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"pub_amenities=has_all:towels,bathroom"}]},{"type":"text","value":" will match listings with\n\"towels\" AND \"bathroom\" in the amenities whereas the query\n"},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"pub_amenities=has_any:towels,bathroom"}]},{"type":"text","value":" will match listings with either\n\"towels\" OR \"bathroom\" (or both). If you don't specify the match mode in\nthe query (i.e. "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"pub_amenities=towels,bathroom"}]},{"type":"text","value":"), by default we use the\nhas_all mathing mode (AND) for multi enums."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"With the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"text"}]},{"type":"text","value":" type, you provide a search query, so splitting values\nwith a comma doesn't make sense. You will just provide a string of text\nas the search query, and the query will be used as described\n"},{"type":"element","tagName":"a","properties":{"href":"/docs/legacy/concepts/how-the-listing-search-works/#keyword-search"},"children":[{"type":"text","value":"in the keyword search explanation"}]},{"type":"text","value":"\nsection."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"With the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"long"}]},{"type":"text","value":" type, you can provide minimum and/or maximum values for\nthe filtering."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For the full query reference, see the\n"},{"type":"element","tagName":"a","properties":{"href":"https://www.sharetribe.com/api-reference/marketplace.html#query-listings","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"/listings/query"}]},{"type":"text","value":"\nendpoint API reference."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"adding-listing-search-schemas","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#adding-listing-search-schemas","ariaLabel":"adding listing search schemas permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Adding listing search schemas"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"FTW defines two search filters in listing public data: category and\namenities. A category is something that is selected from a dropdown of\noptions, so the schema type should be "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"enum"}]},{"type":"text","value":". A listing can have\nmultiple amenities that are also selected from a set of options and\nstored in an array, so the schema type should be "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"multi-enum"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's first see what search schemas we have defined:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"$ flex-cli search -m my-marketplace-dev\n\nSchema for   Scope   Key   Type   Default value   Doc\n"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Let's add the search schemas for the category and amenities:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"$ flex-cli search set --key category --type enum --scope public -m my-marketplace-dev"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"$ flex-cli search set --key amenities --type multi-enum --scope public -m my-marketplace-dev"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"We should now see the details for these new schemas:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"$ flex-cli search -m my-marketplace-dev\n\nSchema for   Scope   Key        Type        Default value   Doc\nlisting      public  amenities  multi-enum\nlisting      public  category   enum"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Note that "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"--schema-for"}]},{"type":"text","value":" option is not needed when adding schema for\n"},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"listing"}]},{"type":"text","value":" as "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"listing"}]},{"type":"text","value":" is the default."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you wish to remove a schema, you can use the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"search unset"}]},{"type":"text","value":" command."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"adding-user-search-schema","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#adding-user-search-schema","ariaLabel":"adding user search schema permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Adding user search schema"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Adding user search schemas is only supported in Flex CLI versions\n1.10.0 and above. Use yarn to update Flex CLI by running\n"},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"yarn global upgrade flex-cli"}]},{"type":"text","value":" or "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"npm update -g flex-cli"}]},{"type":"text","value":" if you are\nusing npm."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"User profile search schema can be useful, if you have an Integration API\napplication that needs to query different sets of users, depending on\nsome value in the user profile's extended data. For instance, if users\nhave "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"age"}]},{"type":"text","value":" attribute stored in their protected data, you can use the\n"},{"type":"element","tagName":"a","properties":{"href":"/docs/legacy/references/extended-data/"},"children":[{"type":"text","value":"/users/query endpoint in the Integration API"}]},{"type":"text","value":"\nto find users of a certain age range."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Search schema for user profiles can be added as follows:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"$ flex-cli search set --schema-for userProfile --key age --type long --scope protected -m my-marketplace-dev"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The above adds a search schema for "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"userProfile"}]},{"type":"text","value":" with "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"long"}]},{"type":"text","value":" type for a\n"},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"key"}]},{"type":"text","value":" named \"age\"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Querying the defined schemas now shows both the listing schemas added on\nthe previous step and the new user profile schema:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"$ flex-cli search -m my-marketplace-dev\n\nSchema for   Scope      Key        Type        Default value   Doc\nlisting      public     amenities  multi-enum\nlisting      public     category   enum\nuserProfile  protected  age        long"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you wish to remove a schema, you can use the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"search unset"}]},{"type":"text","value":" command."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"adding-a-search-schema-with-a-default-value","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#adding-a-search-schema-with-a-default-value","ariaLabel":"adding a search schema with a default value permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Adding a search schema with a default value"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Sometimes, you may want to query listings that do not have a certain\nattibute set. For instance, you may have promoted listings on your\nmarketplace, labelled with a metadata attribute "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"isPromoted: true"}]},{"type":"text","value":". If\nyou only have a handful of promoted listings, you likely do not want to\ntag all other listings with "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"isPromoted: false"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Instead, Flex allows you to set a default value for the search schema –\nall listings that do not have the attribute get returned when querying\nthe default value."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can set the default value for a search schema simply by passing a\n"},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"--default"}]},{"type":"text","value":" flag with the desired default value. To create the search\nschema described above, the Flex CLI command is as follows:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"$ flex-cli search set --key isPromoted --type boolean --scope metadata --default false -m my-marketplace-dev"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Now, if we query all the search schemas on the marketplace, we can see\nthe default value for the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"isPromoted"}]},{"type":"text","value":" schema in the corresponding\ncolumn."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"div","properties":{"className":["gatsby-highlight"],"dataLanguage":"text"},"children":[{"type":"element","tagName":"pre","properties":{"className":["language-text"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"$ flex-cli search -m my-marketplace-dev\n\nSchema for   Scope      Key         Type         Default value   Doc\nlisting      metadata   isPromoted  boolean      false\nlisting      public     amenities   multi-enum\nlisting      public     category    enum\nuserProfile  protected  age         long"}]}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h2","properties":{"id":"summary","style":"position:relative;"},"children":[{"type":"element","tagName":"a","properties":{"href":"#summary","ariaLabel":"summary permalink","className":["anchor","before"]},"children":[{"type":"element","tagName":"svg","properties":{"ariaHidden":"true","focusable":"false","height":"16","version":"1.1","viewBox":"0 0 16 16","width":"16"},"children":[{"type":"element","tagName":"path","properties":{"fillRule":"evenodd","d":"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"},"children":[]}]}]},{"type":"text","value":"Summary"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In this guide, we used Flex CLI to define search schemas for our\nmarketplace. We used the listing category and amenities as examples, as\nFTW-daily expects those. In addition, we looked at adding user search\nschemas for Integration API as well as adding a listing schema with a\ndefault value."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For more information, see the following resources:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/docs/legacy/concepts/how-the-listing-search-works/"},"children":[{"type":"text","value":"How the search works"}]},{"type":"text","value":"\nbackground article"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/docs/legacy/references/extended-data/"},"children":[{"type":"text","value":"Extended data reference"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"API reference for the\n"},{"type":"element","tagName":"a","properties":{"href":"https://www.sharetribe.com/api-reference/marketplace.html#query-listings","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"/listings/query"}]},{"type":"text","value":"\nendpoint in the Marketplace API"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"API reference for the\n"},{"type":"element","tagName":"a","properties":{"href":"https://www.sharetribe.com/api-reference/integration.html#query-listings","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"/listings/query"}]},{"type":"text","value":"\nendpoint in the Integration API"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"API reference for the\n"},{"type":"element","tagName":"a","properties":{"href":"https://www.sharetribe.com/api-reference/integration.html#query-users","target":"_blank","rel":["noopener","noreferrer"]},"children":[{"type":"text","value":"/users/query"}]},{"type":"text","value":"\nendpoint in the Integration API"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/docs/legacy/how-to/extend-listing-data-in-ftw/"},"children":[{"type":"text","value":"Extend listing data in FTW"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"/docs/legacy/how-to/change-search-filters-in-ftw/"},"children":[{"type":"text","value":"Change search filters in FTW"}]}]},{"type":"text","value":"\n"}]}],"data":{"quirksMode":false}},"headings":[{"value":"Extended data types and schema scopes","depth":2},{"value":"Schema types and cardinalities","depth":2},{"value":"Providing multiple query params for a single field","depth":3},{"value":"Adding listing search schemas","depth":2},{"value":"Adding user search schema","depth":2},{"value":"Adding a search schema with a default value","depth":2},{"value":"Summary","depth":2}]}},"pageContext":{"slug":"manage-search-schemas-with-flex-cli","category":"how-to-search"}},
    "staticQueryHashes": ["3794076007","439097193","717698143"]}