Self-Managed Elastic App Search Beta Released



  • Many of you are well familiar with Elasticsearch, which has been downloaded over 100,000,000 times, providing search within the most popular applications the world over. But you might not be familiar with Elastic App Search. Today — for the first time — you can download it and run it within your own infrastructure.

    Elasticsearch Born

    Elasticsearch — you know, it’s for search. Elastic App Search is also for search, and it is built atop Elasticsearch. While Elasticsearch is found at the heart of searching, logging, and data storing infrastructure, it is seldom exposed to the public internet.

    To allow public access to your Elasticsearch data, you might put it behind a proxy server, or wrap its APIs in your own middleware. But then you’ll also need to ponder what to expose, keep it secure, manage authentication, and write your own insulating logic to allow clients to reach your data.

    If you just want to provide search within your application — to index your data, then construct an application or product from it — you will be most interested in Elastic App Search. It is the intelligent, optimized, API wrapper in front of Elasticsearch, and much more.

    Search, Dance

    We can best demonstrate Elastic App Search by experimenting with its key operations — first, there is the creation of your Engine, the conduit that represents your search indexes.

    We will make an Engine called:

    walk-in-the-park
    

    While we can choose from over a dozen different languages, we will choose English, the language that matches our data set:

    curl -X POST 'http://localhost:3002/api/as/v1/engines' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
    -d '{
      "name": "walk-in-the-park"
    }'
    

    An Engine is nothing without documents, so we shall provide some. How about two objects that represent National Parks?

    curl -X POST 'http://localhost:3002/api/as/v1/engines/walk-in-the-park/documents' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
    -d '[
        {
      "description": "This park and the co-managed state parks protect almost half of all remaining coastal redwoods, the tallest trees on earth. There are three large river systems in this very seismically active area, and 37 miles (60 km) of protected coastline reveal tide pools and seastacks. The prairie, estuary, coast, river, and forest ecosystems contain a wide variety of animal and plant species.",
      "nps_link": "https://www.nps.gov/redw/index.htm",
      "states": [
        "California"
      ],
      "title": "Redwood",
      "id": "park_redwood",
      "visitors": 536297,
      "world_heritage_site": true,
      "location": "41.3,-124",
      "acres": 138999.37,
      "square_km": 562.5,
      "date_established": "1968-10-02T05:00:00Z"
    },
    {
      "description": "Bisected north to south by the Continental Divide, this portion of the Rockies has ecosystems varying from over 150 riparian lakes to montane and subalpine forests to treeless alpine tundra. Wildlife including mule deer, bighorn sheep, black bears, and cougars inhabit its igneous mountains and glacial valleys. Longs Peak, a classic Colorado fourteener, and the scenic Bear Lake are popular destinations, as well as the historic Trail Ridge Road, which reaches an elevation of more than 12,000 feet (3,700 m).",
      "nps_link": "https://www.nps.gov/romo/index.htm",
      "states": [
        "Colorado"
      ],
      "title": "Rocky Mountain",
      "id": "park_rocky-mountain",
      "visitors": 4517585,
      "world_heritage_site": false,
      "location": "40.4,-105.58",
      "acres": 265795.2,
      "square_km": 1075.6,
      "date_established": "1915-01-26T06:00:00Z"
    }
    ]'
    

    In response, a simple set of JSON objects have now become indexed, searchable documents, optimized by default for full-text search. The documents exist within your Elasticsearch cluster at the heart of App Search.

    But we have more than text fields, and so we should adjust our schema. Fields can also be of type number, date, or geolocation.

    Want to generate results given proximity to geo-coordinates or a specific date? Or search through a range of numbers? If the schema is right, you can do so at query time.

    curl -X POST 'http://localhost:3002/api/as/v1/engines/walk-in-the-park/schema' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer private-xxxxxxxxxxxxxxxx' \
    -d '{
      "description": "text",
      "nps_link": "text",
      "location": "geolocation",
      "states": "text",
      "title": "text",
      "visitors": "number",
      "world_heritage_site": "text",
      "acres": "number",
      "square_km": "number",
      "date_established": "date"
    }'
    

    Ahh-ha, good good. We are now ready to search through this data, and for that we are going to use a JavaScript client. But first, how about we craft a unique key…

    curl -X POST 'http://localhost:3002/api/as/v1/credentials' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer admin-xxxxxxxxxxxxxxxx' \
    -d '[
    {
      "name": "limited-javascript-search-key",
      "type": "search",
      "read": true,
      "write": false,
      "access_all_engines": false,
      "engines": [
        "walk-in-the-park"
      ]
    }
    ]'
    

    Key acquired: search-lpaewu2xf6uc52dr8med54v8. Along with this key, we have an Engine - which contains an index with multiple data types — and two lush documents over which we can search. And now, to search.

    We will use a JavaScript client as promised, and we will request only the title and a limited description:

    const client = SwiftypeAppSearch.createClient({
      searchKey: 'search-soaewu2ye6uc45dr8mcd54v8',
      engineName: 'walk-in-the-park'
    })
    const query = 'rocky mountain'
    const options = {
      filters: {
        result_field: {
          title: {
            raw: {}
          },
          description: {
            raw: {}
          }
        }
      }
    }
    client
      .search(query, options)
      .then(function(response){ console.log(response) })
      .catch(function(error){ console.log(error) })
    

    Look what we found!

    {
      "meta": {
        "warnings": [],
        "page": {
          "current": 1,
          "total_pages": 4,
          "total_results": 38,
          "size": 10
        },
        "request_id": "ce1a5d2a70113fab5d361b335a76e0ad"
      },
      "results": [
        {
          "title": {
            "raw": "Rocky Mountain"
          },
          "description": {
            "raw": "Bisected north to south by the Continental Divide, this portion of the Rockies has ecosystems"
          },
          "id": {
            "raw": "park_rocky-mountain"
          },
          "_meta": {
            "score": 48.68962
          }
        }
      ]
    }
    

    Stop! Query Time

    At query time, one can adjust the weight of fields, giving greater precedence to specific fields. One can also provide boosts depending on the result values of those fields, receive facet counts, sort, create groups, apply tags, and more — all while collecting analytics data in realtime.

    The Analytics API can be used in conjunction with search; are your top 3 search results often changing? Perhaps your front-end code can request your most popular search results and then re-configure its content or product listings in real-time. Or, perhaps you just want a tidy way to view what users are searching for, finding, and not finding.

    More than just APIs, team members of all kind can add value from the Elastic App Search dashboard. You can view analytics, curate results, add synonyms, configure weights and boosts, and more, all from within an intuitive user interface.

    All Packed Up, Somewhere to Go

    During the beta period, you can spin Elastic App Search up on your own hardware at no charge. To do so, download App Search.

    This self-managed release of Elastic App Search requires that you have Java 8 installed and Elasticsearch 6.4+ running. Elasticsearch requires at least a Basic license. You will receive a licence for free when downloading Elasticsearch from Elastic.co.

    Once the dependencies have been taken care of, enter the decompressed App Search directory and run:

    bin/app-search
    

    And now access http://localhost:3002, login with the default credentials and explore. You can now host and configure App Search however you like.

    Wondering where to start? Index some documents, then see how your data looks within the Reference UI, a foundational, React based open source search experience that you can build on top of, or use from within the dashboard for search experimentation. From there, we have ample documentation that can help you fine tune search relevance and build the next great search experience.

    We’d Love Your Feedback

    Please let us know how you are feeling about Elastic App Search. If you run into any bugs, have any comments or questions, please reach us at: [email protected].

    Elastic App Search, Managed

    If this sounds intriguing, but you are more interested in Elastic App Search as a managed service, you can sign up for a free 14 day trial.



    https://www.elastic.co/blog/elastic-app-search-beta-released

Log in to reply
 

© Lightnetics 2024