# 解决coreseek生成索引时报错WARNING: attribute 'id' not found - IGNORING

**URL:** https://www.shiqidu.com/t/topic/193
**Category:** 开发调优
**Tags:** Sphinx
**Created:** [2017 年7 月 18 日 13:22 UTC](https://www.shiqidu.com/t/topic/193 "2017-07-18T13:22:08Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### 作者： ![Eureka](https://www.shiqidu.com/user_avatar/www.shiqidu.com/eureka/32/5_2.png) [@Eureka](https://www.shiqidu.com/u/Eureka)
#### 发布日期： [2017 年7 月 18 日 13:22 UTC](https://www.shiqidu.com/t/topic/193/1 "2017-07-18T13:22:08Z")

</div>

今天在配置完`sphinx`新索引后，生成索引时报错

```bash
indexing index 'eaxing'...
WARNING: attribute 'id' not found - IGNORING
collected 22 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 22 docs, 27644 bytes
total 0.011 sec, 2414112 bytes/sec, 1921.22 docs/sec

```

原因是`sphinx`不能使用主键来做属性字段，而我的源配置里是这么写的

```bash
sql_query = SELECT id, discussion_id,content FROM sq_posts
sql_attr_uint = id
sql_attr_uint = discussion_id

```

`id`是我`posts`表的主键，所以需要给个别名，like this

```bash
sql_query = SELECT id,id as aid, discussion_id,content FROM sq_posts
sql_attr_uint = aid
sql_attr_uint = discussion_id

```

然后再试试生成索引

```bash
./indexer -c /usr/local/coreseek/etc/csft.conf --all --rotate

```

```bash
indexing index 'eaxing'...
collected 22 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 22 docs, 27644 bytes
total 0.010 sec, 2573210 bytes/sec, 2047.84 docs/sec

```

ok了，这下就没错了。

---

<div class="post-metadata">

### 作者： ![zousaisai](https://www.shiqidu.com/user_avatar/www.shiqidu.com/zousaisai/32/470_2.png) [@zousaisai](https://www.shiqidu.com/u/zousaisai)
#### 发布日期： [2017 年7 月 27 日 13:54 UTC](https://www.shiqidu.com/t/topic/193/2 "2017-07-27T13:54:02Z")

</div>

555555

---

<div class="post-metadata">

### 作者： ![caojie](https://www.shiqidu.com/user_avatar/www.shiqidu.com/caojie/32/465_2.png) [@caojie](https://www.shiqidu.com/u/caojie)
#### 发布日期： [2017 年7 月 30 日 08:34 UTC](https://www.shiqidu.com/t/topic/193/3 "2017-07-30T08:34:24Z")

</div>

666

---

<div class="post-metadata">

### 作者： ![Eureka](https://www.shiqidu.com/user_avatar/www.shiqidu.com/eureka/32/5_2.png) [@Eureka](https://www.shiqidu.com/u/Eureka)
#### 发布日期： [2017 年7 月 30 日 08:44 UTC](https://www.shiqidu.com/t/topic/193/4 "2017-07-30T08:44:01Z")

</div>

@草芥: 777
