|
| 1 | +<template> |
| 2 | + <reactive-base |
| 3 | + app="yc-companies-dataset" |
| 4 | + url="https://appbase-demo-ansible-abxiydt-arc.searchbase.io" |
| 5 | + credentials="a03a1cb71321:75b6603d-9456-4a5a-af6b-a487b309eb61" |
| 6 | + :enable-appbase="true" |
| 7 | + > |
| 8 | + <div class="container"> |
| 9 | + <h2>Vector Search with ReactiveSearch</h2> |
| 10 | + <search-box |
| 11 | + component-id="search" |
| 12 | + :data-field="['name', 'one_liner']" |
| 13 | + placeholder="Vector search on a dataset of startup companies, e.g. search for 'gene editing'" |
| 14 | + :autosuggest="false" |
| 15 | + style="margin-bottom: 1rem" |
| 16 | + :URLParams="true" |
| 17 | + /> |
| 18 | + <selected-filters /> |
| 19 | + |
| 20 | + <div class="layout"> |
| 21 | + <div class="facet-container"> |
| 22 | + <multi-list |
| 23 | + component-id="industries" |
| 24 | + data-field="industries.keyword" |
| 25 | + title="Industries" |
| 26 | + placeholder="Filter by industries" |
| 27 | + :show-search="true" |
| 28 | + style="margin-bottom: 1rem" |
| 29 | + :aggregation-size="96" |
| 30 | + :inner-class="{ list: 'facet-list' }" |
| 31 | + /> |
| 32 | + </div> |
| 33 | + |
| 34 | + <div class="results-container"> |
| 35 | + <reactive-list |
| 36 | + component-id="results" |
| 37 | + vector-data-field="vector_data" |
| 38 | + :size="20" |
| 39 | + :candidates="20" |
| 40 | + :pagination="true" |
| 41 | + :react="{ and: ['search', 'industries'] }" |
| 42 | + :include-fields="[ |
| 43 | + 'name', |
| 44 | + 'one_liner', |
| 45 | + 'long_description', |
| 46 | + 'team_size', |
| 47 | + 'stage', |
| 48 | + 'industries', |
| 49 | + 'website', |
| 50 | + 'small_logo_thumb_url', |
| 51 | + ]" |
| 52 | + > |
| 53 | + <template #render="{ data }"> |
| 54 | + <div v-for="item in data" :key="item._id" class="result-item"> |
| 55 | + <img |
| 56 | + v-if="item.small_logo_thumb_url" |
| 57 | + :src="item.small_logo_thumb_url" |
| 58 | + :alt="`${item.name} logo`" |
| 59 | + class="company-logo" |
| 60 | + /> |
| 61 | + <div class="company-info"> |
| 62 | + <h3 class="company-name">{{ item.name }}</h3> |
| 63 | + <p class="company-oneliner"> |
| 64 | + {{ item.one_liner || item.long_description }} |
| 65 | + </p> |
| 66 | + <div class="company-meta"> |
| 67 | + <span v-if="item.team_size" class="meta-item"> |
| 68 | + Team: {{ item.team_size }} |
| 69 | + </span> |
| 70 | + <span v-if="item.stage" class="meta-item"> |
| 71 | + Stage: {{ item.stage }} |
| 72 | + </span> |
| 73 | + </div> |
| 74 | + <div |
| 75 | + v-if="item.industries && item.industries.length > 0" |
| 76 | + class="company-tags" |
| 77 | + > |
| 78 | + <span |
| 79 | + v-for="ind in item.industries" |
| 80 | + :key="ind" |
| 81 | + class="tag" |
| 82 | + > |
| 83 | + {{ ind }} |
| 84 | + </span> |
| 85 | + </div> |
| 86 | + <a |
| 87 | + v-if="item.website" |
| 88 | + :href="item.website" |
| 89 | + target="_blank" |
| 90 | + rel="noopener noreferrer" |
| 91 | + class="company-link" |
| 92 | + > |
| 93 | + Visit website |
| 94 | + </a> |
| 95 | + </div> |
| 96 | + </div> |
| 97 | + </template> |
| 98 | + <template #renderNoResults> |
| 99 | + <div>No results found</div> |
| 100 | + </template> |
| 101 | + </reactive-list> |
| 102 | + |
| 103 | + <!-- Debug Panel - Shows the queries and responses --> |
| 104 | + <div class="debug-panel"> |
| 105 | + <h3>Debug Information</h3> |
| 106 | + <p> |
| 107 | + This example demonstrates vector search using the |
| 108 | + <code>vectorDataField</code> and <code>candidates</code> props. |
| 109 | + </p> |
| 110 | + <ul> |
| 111 | + <li> |
| 112 | + When you search in the search box, the value is used for the |
| 113 | + vector search |
| 114 | + </li> |
| 115 | + <li> |
| 116 | + The <code>vectorDataField</code> prop points to the vector field |
| 117 | + in your index |
| 118 | + </li> |
| 119 | + <li> |
| 120 | + The <code>candidates</code> prop controls how many nearest |
| 121 | + neighbors to return |
| 122 | + </li> |
| 123 | + </ul> |
| 124 | + </div> |
| 125 | + </div> |
| 126 | + </div> |
| 127 | + </div> |
| 128 | + </reactive-base> |
| 129 | +</template> |
| 130 | + |
| 131 | +<script> |
| 132 | +import { |
| 133 | + ReactiveBase, |
| 134 | + SearchBox, |
| 135 | + MultiList, |
| 136 | + ReactiveList, |
| 137 | + SelectedFilters, |
| 138 | +} from '@appbaseio/reactivesearch-vue' |
| 139 | +
|
| 140 | +export default { |
| 141 | + name: 'App', |
| 142 | + components: { |
| 143 | + ReactiveBase, |
| 144 | + SearchBox, |
| 145 | + MultiList, |
| 146 | + ReactiveList, |
| 147 | + SelectedFilters, |
| 148 | + } |
| 149 | +} |
| 150 | +</script> |
0 commit comments