Giter Club home page Giter Club logo

azure-search-react-template's Introduction

Azure Cognitive Search UI

This sample is a React template for Azure Cognitive Search. It leverages the Azure SDK for Javascript/Typescript and Azure Static Web Apps to make it easy to get up and running with a simple web application.

You can view the resulting web application here: https://victorious-beach-0ab88b51e.azurestaticapps.net/

Screenshot of sample web app

You can easily deploy the sample onto Azure or run it locally by following the steps below.

Running the application locally

To run the sample locally, follow the steps below.

Prerequisites

Setup

  1. Clone (or Fork and Clone) this repository

  2. Rename the api/local.settings.json.rename file to api/local.settings.json.

The local.settings.json file holds all of the keys that the application needs.

For this sample, there is a search index using the goodbooks-10k dataset that that is publicly available using the connection information below. The index consists of 10,000 popular books that we'll search over in our application.

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "FUNCTIONS_WORKER_RUNTIME": "node",
    "SearchApiKey": "03097125077C18172260E41153975439",
    "SearchServiceName": "azs-playground",
    "SearchIndexName": "good-books",
    "SearchFacets": "authors*,language_code"
  }
}

Run the app locally

This project can be run anywhere, but VS Code is required for local debugging.

  1. Open the application with VS Code.

Running the front-end

  1. Install front-end dependencies...

    npm install
  2. Run the front-end project in the browser (automatically opens a browser window).

    npm start

Running the API

  1. From VS Code, press F5

Deploying this sample

Prerequisites

  • A GitHub account
  • An Azure subscription

Forking the repo

To start off, select Use this template above. This will create your own copy of the code that you can deploy and edit as you please.

Use this template screenshot

Creating the web app

Next, you need to create a Static Web App in the Azure portal. Click the button below to create one:

Deploy to Azure button

This will walk you through the process of creating the web app and connecting it to your GitHub repo.

After connecting to the repo, you'll be asked to include some build details. Set the Build Presets to React and then leave the other default values:

Azure Static Web Apps Configuration Screenshot

Once you create the static web app, it will automatically deploy the web app to a URL you can find within the portal.

Azure Static Web Apps Configuration Screenshot

The last thing you need to do is select configuration and then edit the application settings to add the credentials from local.settings.json. It may take a few minutes for this blade to become available in the portal.

Azure Static Web Apps Configuration Screenshot

Additional documentation can be found in the docs folder.

azure-search-react-template's People

Contributors

dalibormesaric avatar dependabot[bot] avatar dereklegenzoff avatar heidisteen avatar mattsavarino avatar msftgits avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

azure-search-react-template's Issues

Deployment clarification

How this application can be deployed in App Service Web App (not as Static web app, Static web app is still preview so it cant be used in production) ?

Proxy Error

I have successfully deployed this repo on azure, modifying it to consume my custom index.

But when trying to deploy locally, I get the error in the VS-code terminal

Proxy error: Could not proxy request /.auth/me from localhost:3000 to http://127.0.0.1:7071.

The "Sign In" button on the top-right of the screen is absent and the search does not find any items.

Deployment query

How this application can be deployed in App Service Web App (not as Static web app, Static web app is still preview so it cant be used in production) ?

Missing Backend / Proxy Config? Proxy error: Could not proxy request /.auth/me from localhost:3000 to http://localhost:7071/.

Hi,

Following the steps as documented here builds and runs the site, but the search does not appear to be functional, it gives:

Proxy error: Could not proxy request /.auth/me from localhost:3000 to http://localhost:7071/.

I'm not sure if there's some configuration not documented here which I need to do: but what puzzles me is why are you defining a proxy for port 7071 without anything to connect to?

Sorry if I've misunderstood - and if this is a separate project we are supposed to setup not outlined here

Kind regards,

Roger Davies

multiple api calls

I added a logging command in src/pages/Search/Search.js

    axios.post( '/api/search', body)
        .then( response => {
            setResults(response.data.results);
            setFacets(response.data.facets);
            setResultCount(response.data.count);
            setIsLoading(false);
        } )
        .catch(error => {
            console.log(error);
            setIsLoading(false);
        });
    
  }, [q, top, skip, filters]);


  console.log(results)

and find that a single search query gives many identical outputs of results to the console.

Screen Shot 2022-10-18 at 9 16 47 pm

Unless I am mistaken, this means that for a single submission of a query, the API is being called many times. Is this correct? I came across this behaviour when analyzing the telemetry data in Application Insights but found I can reproduce it just by logging to the console. If this is correct it would seem less than ideal, in particular it will result in unfair cost my client.

Duplicate Search Api Calls

Thank you for this great template.

It appears the each request to search api is happening twice when searching or paging. Is this intentional or a possible bug?

The screen shots below are for a single request.

Screen Shot 2021-05-26 at 5 02 31 PM

Screen Shot 2021-05-26 at 5 04 54 PM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.