# Getting started

To start to use SolrExpress, just follow follow steps:

1. Create a class to represent your collection, extend **Document** class and use attributes to indicate Solr fields.

```csharp
    public class TechProductDocument : Document
    {
        [SolrField("manu")]
        public string Manufacturer { get; set; }

        [SolrField("store")]
        public GeoCoordinate StoredAt { get; set; }
    }
```

1. Choose your favorite Dependency Injection provider (SolrExpress.DI.Autofac, SolrExpress.DI.CoreClr, SolrExpress.DI.Ninject or SolrExpress.DI.SimpleInject) and add reference to package
2. Add reference to correct Solr provider (SolrExpress.Solr4 or SolrExpress.Solr5)
3. Configure SolrExpress setting Solr host address for **each** collection

```csharp
    public void ConfigureServices(SomeDIContainer services)
    {
        services
            // This extension is from SolrExpress.DI.<Your favorite DI provider>
            .AddSolrExpress<TechProduct>(builder => builder
                .UseHostAddress("http://localhost:8983/solr/techproducts")
                // This extension is from SolrExpress.Solr5
                .UseSolr5()); // Or UseSolr4 from SolrExpress.Solr4
    }
```

1. Configue search parameters, execute, read results and enjoy :)

```csharp
    public void MyAmazingSearch(DocumentCollection<TechProduct> techProducts)
    {
        // Initial search settings (configure to result facet field Categories and filter by field id using value "205325092")
        var searchResult = techProducts
            .Select()
            .Fields(d => d.Id, d => d.Manufacturer)
            .FacetField(d => d.Categories)
            .Filter(d => d.Id, "205325092")
            .Execute();

        // Get general information about search, documents and facets from search result
        searchResult
            .Information(out var information)
            .Document(out var documents)
            .Facets(out var facets);
    }
```

**NOTES**

1. Class ***TechProductDocument*** represents a document in Solr collection and to be easy to identitify this, I call this class with the same name of the Solr collection (techproducts) but you can choose any name what you want, just remember, extends ***Document*** class;
2. To example purposes, I set collection address in hard code.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://solr-express.gitbook.io/docs/5.0.1/tutorials/getting-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
